Extract DN (Distinguished Names) from a X.509 certificate using iOS API

Viewed 535

I need to extract the DN (Distinguished Names) from a X.509 certificate using iOS native API. Without using any 3rd party libraries like OpenSSL.

I need to extract it as a string with the following format, as defined by X.509 standard:

CN=John Smith, OU=Test, O=IBM, C=GB

I found this method which seems to return what I'm looking for, according to its signature:

CFDataRef SecCertificateCopyNormalizedSubjectSequence(SecCertificateRef certificate);

This method returns a DER encoded sequence. The method header comment says:

The subject is a sequence in the format used by SecItemCopyMatching. The content returned is a DER-encoded X.509 distinguished name. For a display version of the subject, call SecCertificateCopyValues.

The issue is that SecCertificateCopyValues method is available for macOS only.

Is there any alternative way to extract the string representation of the DER encoded values from the returned data using iOS available API?

0 Answers
Related