diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-05 14:14:19 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-05 14:14:19 +0100 |
| commit | 6458fece2856ded3a9a44fb26378165495e5e280 (patch) | |
| tree | d4c8c05899466f04c792dd7228d21c683e618289 /src | |
| parent | b038dc192bdac76da3b1bebdd6b448e8be830814 (diff) | |
Speculative change from master to X509IssuerName order.
Diffstat (limited to 'src')
| -rw-r--r-- | src/certificates.cc | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/certificates.cc b/src/certificates.cc index 565475a8..1c0ef984 100644 --- a/src/certificates.cc +++ b/src/certificates.cc @@ -178,21 +178,27 @@ Certificate::get_name_part (X509_NAME* n, int nid) return asn_to_utf8 (X509_NAME_ENTRY_get_data (X509_NAME_get_entry (n, p))); } - string -Certificate::name_for_xml (X509_NAME * n) +Certificate::name_for_xml (X509_NAME* name) { - DCP_ASSERT (n); - - string s = String::compose ( - "O=%1,OU=%2,CN=%3,dnQualifier=%4", - get_name_part (n, NID_organizationName), - get_name_part (n, NID_organizationalUnitName), - get_name_part (n, NID_commonName), - get_name_part (n, NID_dnQualifier) - ); - - boost::replace_all (s, "+", "\\+"); + assert (name); + + BIO* bio = BIO_new (BIO_s_mem ()); + if (!bio) { + throw MiscError ("could not create memory BIO"); + } + + X509_NAME_print_ex (bio, name, 0, XN_FLAG_RFC2253); + int n = BIO_pending (bio); + char* result = new char[n + 1]; + n = BIO_read (bio, result, n); + result[n] = '\0'; + + BIO_free (bio); + + string s = result; + delete[] result; + return s; } |
