我創建了這樣一個公共密鑰:如何從目標C中的文件創建私鑰?
NSString *pkFilePath = [[NSBundle mainBundle] pathForResource:@"public_key" ofType:@"der"];
NSData *myCertData = [NSData dataWithContentsOfFile:pkFilePath];
SecCertificateRef cert = SecCertificateCreateWithData (kCFAllocatorDefault, (CFDataRef)myCertData);
CFArrayRef certs = CFArrayCreate(kCFAllocatorDefault, (const void **) &cert, 1, NULL);
SecTrustRef trust;
SecPolicyRef myPolicy = SecPolicyCreateBasicX509();
SecTrustCreateWithCertificates(certs, myPolicy, &trust);
SecTrustResultType trustResult;
SecTrustEvaluate(trust, &trustResult);
SecKeyRef pub_key_leaf = SecTrustCopyPublicKey(trust);
NSLog(@"%@",pub_key_leaf);
但如何從文件創建私有密鑰?
這裏是一些相關的代碼來創建一個私鑰,但我沒有得到如何使用我的私鑰文件從此創建私鑰。
什麼格式是你的私鑰? – 2013-04-09 16:00:50
@MarcusAdams它在privatekey.pem文件中。 – 2013-04-10 07:09:48