项目需要RSA加密,网上看了下,按照以下代码从证书中获取公钥加密:
但是运行到 OSStatus status = SecTrustCreateWithCertificates(myCertificate,myPolicy,&myTrust);老是崩溃,显示myCertificate为空,什么原因,和证书类型有关?我现在想根据cer类型的来加密。
NSString *certPath = [[NSBundle mainBundle] pathForResource:@"myidentifier" ofType:@"cer"];
SecCertificateRef myCertificate = nil;
NSData *certificateData = [[NSData alloc] initWithContentsOfFile:certPath];
//[certificateData base64Encoding]
myCertificate = SecCertificateCreateWithData(kCFAllocatorDefault, (__bridge CFDataRef)certificateData);
SecPolicyRef myPolicy = SecPolicyCreateBasicX509();
SecTrustRef myTrust;
OSStatus status = SecTrustCreateWithCertificates(myCertificate,myPolicy,&myTrust);
但是运行到 OSStatus status = SecTrustCreateWithCertificates(myCertificate,myPolicy,&myTrust);老是崩溃,显示myCertificate为空,什么原因,和证书类型有关?我现在想根据cer类型的来加密。