好的,我知道有这么多...关于这个问题的许多问题,但是没有人可以解决我的问题。 我的iOS版本是6.1。我通过相互身份验证尝试了HTTPS连接到我们的服务器。但是有一个错误:
“发生连接失败:SSL问题(可能的原因可能包括错误/过期/自签名证书,时钟设置为错误日期)”; NSUnderlyingError =“错误域= NSOSStatusErrorDomain代码= -9807 \”操作无法完成。 (OSStatus错误-9807。)\“”
以下是我的代码:
NSURL *httpsUrl = [NSURL URLWithString:@"https://192.168.100.78"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:httpsUrl];
SecIdentityRef identity = NULL;
SecTrustRef trust = NULL;
NSData *PKCS12Data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"myios" ofType:@"p12"]];
if (!PKCS12Data) {
NSLog(@"certificate not found");
}
if (![self extractIdentity:&identity andTrust:&trust fromPKCS12Data:PKCS12Data]) {
NSLog(@"NO");
return;
};
[request setDelegate:self];
[request setTimeOutSeconds:20];
[request setRequestMethod:@"POST"];
[request setClientCertificateIdentity:identity];
[request setValidatesSecureCertificate:NO];
[request startSynchronous];
NSError * error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog(@"response is : %@",response);
} else {
NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
NSLog(@"%@",[error userInfo]);
}
感谢。