我有一個使用自簽名SSL證書並運行Web服務的tomcat服務器。我正嘗試使用Restkit連接到Web服務。但是,我收到與證書有效性相關的錯誤。這裏是我的代碼:ios - Restkit和SSL證書錯誤
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];
感謝您的幫助! –