SecCertificateRef from PEM file
SecCertificateRef from PEM file
- Subject: SecCertificateRef from PEM file
- From: Ryan Govostes <email@hidden>
- Date: Wed, 3 Jun 2009 13:35:57 -0400
- Resent-date: Wed, 3 Jun 2009 13:37:36 -0400
- Resent-from: Ryan Govostes <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: email@hidden
Hello,
I have a certificate stored on disk in PEM format. I'd like to read it
into a SecCertificateRef.
From some cursory reading, it looks like a PEM certificate is just
Base64-encoded DER. So I manually decoded the Base64 and wrote the
binary data to a file, which was read in like:
SecCertificateRef rootCert;
CSSM_DATA cssmdata;
cssmdata.Data = [certdata bytes];
cssmdata.Length = [certdata length];
SecCertificateCreateFromData(&cssmdata, CSSM_CERT_X_509v3,
CSSM_CERT_ENCODING_DER, &rootCert);
At this point SecCertificateCreateFromData returns noErr and things
look like they're going well. However, any time I try to use the root
certificate, i.e.,
CFStringRef commonName;
SecCertificateCopyCommonName(rootCert, &commonName);
SecCertificateCopyCommonName returns errSecDataNotAvailable (which is
unexplained). I take it that this means that the certificate was not
properly loaded from the data?
Is there a better way to go about reading in the PEM file, other than
doing so manually like I have done? Am I doing something incorrect
that would cause the error code I am seeing?
Thanks,
Ryan Govostes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden