0

自己署名 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];
4

3 に答える 3

2

NSURLConnection は、同期呼び出しでの認証チャレンジに対応していません。これを機能させるには、非同期呼び出しを行う必要があります。

于 2013-01-13T00:15:33.427 に答える
1

私の場合、RKClient で disableCertificateValidation を設定していましたが、別の RKClient を使用する RKObjectManager を使用していました。RKObjectManager の初期化の後に配置された次の行は、トリックを行いました。

[RKObjectManager sharedManager].client.disableCertificateValidation = YES;
于 2013-09-10T11:42:21.903 に答える