2013-11-22 111 views
1

我正在使用openSSL連接到服務器。X.509證書轉換爲SecCertificateRef

當我獲得X509格式的證書/鏈後,我想使用Apple的安全框架來驗證證書。

爲了做到這一點,我需要將X.509結構翻譯爲SecCertificateRef。

下面失敗..

X509 *x509cert = ..; 
SecCertificateRef certificateRef = SecCertificateCreateWithData(NULL, X509Cert); 

SecCertificateCreateWithData在CFDataRef(DER編碼的X.509證書)格式要求的數據。

有沒有人有這樣的示例代碼?

回答

2

什麼是證書的文件擴展名? 您可能必須將其轉換爲DER格式

openssl x509 -outform der -in certificate.pem -out certificate.der