int gnutls_x509_dn_oid_known (const char *oid);
- const char* gnutls_x509_dn_oid_name (const char *oid);
+#define GNUTLS_X509_DN_OID_RETURN_OID 1
+ const char* gnutls_x509_dn_oid_name (const char *oid, unsigned int flags);
/* Read extensions by OID. */
int gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, int indx,
/**
* gnutls_x509_dn_oid_name:
* @oid: holds an Object Identifier in a null terminated string
+ * @flags: 0 or %GNUTLS_X509_DN_OID_*
*
- * This function will return the name of a known DN OID.
+ * This function will return the name of a known DN OID. If
+ * %GNUTLS_X509_DN_OID_RETURN_OID is specified this function
+ * will return the given OID if no descriptive name has been
+ * found.
*
* Returns: A null terminated string or NULL otherwise.
*
* Since: 3.0.0
**/
const char*
-gnutls_x509_dn_oid_name (const char *oid)
+gnutls_x509_dn_oid_name (const char *oid, unsigned int flags)
{
int i = 0;
}
while (_oid2str[i].oid != NULL);
- return NULL;
+ if (flags & GNUTLS_X509_DN_OID_RETURN_OID) return oid;
+ else return NULL;
}
const char *
* Name (you need a parser just to read a name in the X.509 protoocols!!!)
*/
-/* Converts the given OID to an ldap acceptable string or
- * a dotted OID.
- */
-static const char *
-oid2ldap_string (const char *oid)
-{
- const char *ret;
-
- ret = gnutls_x509_dn_oid_name (oid);
- if (ret)
- return ret;
-
- /* else return the OID in dotted format */
- return oid;
-}
-
/* Escapes a string following the rules from RFC4514.
*/
static char *
}
}
- ldap_desc = oid2ldap_string (oid);
+ ldap_desc = gnutls_x509_dn_oid_name (oid, GNUTLS_X509_DN_OID_RETURN_OID);
printable = _gnutls_x509_oid_data_printable (oid);
/* leading #, hex encoded value and terminating NULL */