Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios SecPKCS12Import不返回任何项目_Ios_Ssl_Ios6 - Fatal编程技术网

Ios SecPKCS12Import不返回任何项目

Ios SecPKCS12Import不返回任何项目,ios,ssl,ios6,Ios,Ssl,Ios6,我想将某些用于TLS验证的CA证书添加到iOS 6应用程序的密钥链中。证书包含在应用程序包中。我不想添加在几个示例中描述的任何标识(私钥/证书组合) SecPKCS12Import调用不返回任何错误,但不幸的是,它也不返回任何证书 为了让您重现我的步骤,我以Google中间证书(“Google Internet Authority”)为例,在下载的PEM证书上运行以下命令: 控制台结果输出为“找到证书:0”。certData变量将填充正确的字节数,如果我更改提供的密码,结果将更改为errSec

我想将某些用于TLS验证的CA证书添加到iOS 6应用程序的密钥链中。证书包含在应用程序包中。我不想添加在几个示例中描述的任何标识(私钥/证书组合)

SecPKCS12Import
调用不返回任何错误,但不幸的是,它也不返回任何证书

为了让您重现我的步骤,我以Google中间证书(“Google Internet Authority”)为例,在下载的PEM证书上运行以下命令:

控制台结果输出为“找到证书:0”。certData变量将填充正确的字节数,如果我更改提供的密码,结果将更改为errSecAuthFailed


你知道问题可能是什么吗?

我认为这是一个bug,请参阅相关问题和bug

由于您只需要一个证书,而不需要私钥,因此我将从DER格式文件导入证书

$ openssl x509 -in google.pem -out google.der -outform DER
$ openssl x509 -in google.der -noout -text
捆绑DER证书文件并将其导入:

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);

我认为这是一个bug,请参阅相关问题和bug

由于您只需要一个证书,而不需要私钥,因此我将从DER格式文件导入证书

$ openssl x509 -in google.pem -out google.der -outform DER
$ openssl x509 -in google.der -noout -text
捆绑DER证书文件并将其导入:

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);

在我的情况下,它确实起了作用。需要注意的一点是,密码短语不相等。“谷歌”!=“通过:谷歌”。在我的例子中,它确实起了作用。需要注意的一点是,密码短语不相等。“谷歌”!=“通行证:谷歌”。