SSL Identity Certificate to run an HTTPS Server on iOS

后端 未结 2 494
滥情空心
滥情空心 2020-12-17 01:10

I\'m trying to build an HTTPS server in an iOS app, in order to act as a proxy between my web-app and my external server.

I have managed to make an

相关标签:
2条回答
  • 2020-12-17 01:51

    It looks like you need to import the identity using a PKCS #12 file. See listing 2-2 in https://developer.apple.com/library/ios/#documentation/Security/Conceptual/CertKeyTrustProgGuide/iPhone_Tasks/iPhone_Tasks.html#//apple_ref/doc/uid/TP40001358-CH208-SW13 .

    0 讨论(0)
  • 2020-12-17 01:56

    I will post a separate answer, as comments are not suitable for code sharing.
    Here is what I use to import my PKCS12:

    CFArrayRef keyref = NULL;
    OSStatus sanityChesk = SecPKCS12Import((__bridge CFDataRef)p12Data, 
                                           (__bridge CFDictionaryRef)[NSDictionary 
                                                                      dictionaryWithObject:password 
                                                                      forKey:(__bridge id)kSecImportExportPassphrase], 
                                           &keyref);
    
    if (sanityChesk != noErr) {
        NSLog(@"Error while importing pkcs12 [%d]", sanityChesk);
        return nil;
    }
    
    NSArray *keystore = (__bridge_transfer NSArray *)keyref;
    

    The complete p12 content will be in the keystore array.

    0 讨论(0)
提交回复
热议问题