我有一个使用自签名 SSL 证书并运行 Web 服务的 tomcat 服务器。我正在尝试使用 Restkit 连接到 Web 服务。但是,我收到与证书有效性相关的错误。这是我的代码:
NSURL *url=[NSURL URLWithString:baseURL];
RKClient *client = [RKClient clientWithBaseURL:url];
client.disableCertificateValidation=YES;
RKRequest *request = [client requestWithResourcePath:[NSString stringWithFormat:@"/addEvent?deviceID=%@&eventID=%@",deviceID,eventID]];
request.disableCertificateValidation=YES;
request.delegate=self;
RKResponse *response = [request sendSynchronously];
此请求失败并出现以下错误:
2013-01-09 15:11:53.931 Mobile_ACPL[5761:907] The certificate for this server is invalid. You might be connecting to a server that is pretending to be “notify.acpl.lib.in.us” which could put your confidential information at risk.
即使我已将 disableCertificateValidation 设置为 YES,我也会收到此错误。我怎样才能得到这个工作?
编辑:我尝试添加证书,如下所示:https ://github.com/RestKit/RestKit/pull/131
我仍然得到相同的结果。
编辑 2:看起来错误消息正在 RKRequest.m 中的这一行设置:
payload = [NSURLConnection sendSynchronousRequest:_URLRequest returningResponse:&URLResponse error:&error];