我正在尝试获取用于我的应用程序的自签名证书。
我目前正在使用ASIHTTPRequest库,如下所示:
- (IBAction)sendHttpsRequest
{
//Set request address
NSMutableString *databaseURL = [[NSMutableString alloc] initWithString:@"https://142.18.87.46:443"];
//call ASIHTTP delegates (Used to connect to database)
NSURL *url = [NSURL URLWithString:databaseURL];
//This sets up all other request
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request setValidatesSecureCertificate:YES];
[request startAsynchronous];
}我将setValidatesSecureCertificate设置为YES,希望会发生一些事情,但显然什么都没有发生,因为我不确定我必须做什么。
这是我在日志中看到的错误
2011-12-06 14:27:33.514 connectionTest[916:207] Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred: SSL problem (Possible causes may include a bad/expired/self-signed certificate, clock set to wrong date)" UserInfo=0x683a860 {NSUnderlyingError=0x68390d0 "The operation couldn’t be completed. (OSStatus error -9807.)", NSLocalizedDescription=A connection failure occurred: SSL problem (Possible causes may include a bad/expired/self-signed certificate, clock set to wrong date)}任何帮助都将不胜感激。
发布于 2011-12-06 09:42:54
我将setValidatesSecureCertificate设置为YES,希望会发生一些事情,但显然什么都没有发生,因为我不确定我必须做什么。
这就是问题所在。默认为YES,您需要将其设置为NO。由于您的证书是自签名的,因此iOS无法验证证书--系统中没有对证书进行签名的受信任的颁发机构,因此它没有判断证书是否有效的依据。因此,如果您要求它验证证书(这是默认设置),它必须拒绝它。您必须禁用证书验证才能使自签名证书生效。
https://stackoverflow.com/questions/8394293
复制相似问题