4

自己署名証明書を使用して、AFNetwork を使用して iOS アプリを Web サーバーに接続したいと考えています。github で解決策を見つけました ( https://github.com/AFNetworking/AFNetworking/pull/694 ) 試してみたところ、証明書のピン留めは機能しているようですが、別のエラーが発生しました:

エラー Domain=NSURLErrorDomain Code=-1012 「操作を完了できませんでした。(NSURLErrorDomain エラー -1012)」 UserInfo=0x7bc2090 {NSErrorFailingURLKey=(私のドメイン)}

このエラーが AFNetworking フレームワークと自己署名証明書に関係しているかどうかを知っている人はいますか?

解決済み: エラーの解決策が見つかりました。SSLPinningMode を AFSSLPinningModeCertificate に設定する必要がありましたが、動作するようになりました。

AFJSONRequestOperation *operation =[AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSDictionary *resDictionary = (NSDictionary *)JSON;
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
    NSLog(@"%@",error);
}];
operation.SSLPinningMode = AFSSLPinningModeCertificate;
[operation start];
4

1 に答える 1

0

この回避策を試してください。

AFJSONRequestOperation *operation =[AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSDictionary *resDictionary = (NSDictionary *)JSON;
}
                                                                                   failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
                                                                                       NSLog(@"%@",error);
                                                                                   }];
operation.securityPolicy.allowInvalidCertificates = YES;
[operation start];
于 2013-10-10T12:51:20.997 に答える