SecPKCS12Import does not return any items

前端 未结 1 1532
逝去的感伤
逝去的感伤 2021-01-07 01:58

I want to add certain CA certificates for TLS validation to the keychain of my iOS 6 application. The certificates are included in the Application Bundle. I do not

相关标签:
1条回答
  • 2021-01-07 02:22

    I'd say that's a bug, see related question SSL Identity Certificate to run an HTTPS Server on iOS and bug SecPKCS12Import returns empty array when certificate expires after Jan 1st 10000.

    As you only want a certificate, without the private key, I'd import the certificate from a DER format file.

    $ openssl x509 -in google.pem -out google.der -outform DER
    $ openssl x509 -in google.der -noout -text
    

    Bundle DER certificate file and import it:

    NSString *path = [[NSBundle mainBundle] pathForResource:@"google" ofType:@"der"];
    NSData *derData = [NSData dataWithContentsOfFile:path];
    SecCertificateRef cert = SecCertificateCreateWithData(NULL, (CFDataRef)derData);
    
    // add cert to KeyChain or use it as you need
    
    CFRelease(cert);
    
    0 讨论(0)
提交回复
热议问题