2013-10-31 32 views
0

使用自簽名證書建立到我的服務器的連接時出現問題。在RestKit 0.10.3中,證書一切正常。RestKit 0.20.3使用證書進行不完整初始化

我初始化RestKit這樣的:

AFHTTPClient * client = [AFHTTPClient clientWithBaseURL:baseURl]; 
    [client setDefaultHeader:@"Accept" value:RKMIMETypeJSON]; 
    client.defaultSSLPinningMode = AFSSLPinningModeCertificate; 
    client.allowsInvalidSSLCertificate = YES; 

    RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client]; 
    objectManager.managedObjectStore = managedObjectStore; 

但SSL證書被忽略 - 它不會被加載AFNetworking。

當我創建這樣

NSMutableURLRequest *request = [[RKObjectManager sharedManager] requestWithObject:nil method:RKRequestMethodGET path:[@"/myResource"] parameters:nil]; 

RKHTTPRequestOperation *httpRequestOperation = [[RKHTTPRequestOperation alloc] initWithRequest:request]; 
httpRequestOperation.SSLPinningMode = AFSSLPinningModeCertificate; 

RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithHTTPRequestOperation:httpRequestOperation 
responseDescriptors:[RKObjectManager sharedManager].responseDescriptors]; 

獲取證書加載,但該請求與此消息反正失敗的請求:

2013-10-31 11:52:12.920 myApp[87552:651b] E restkit.network:RKObjectRequestOperation.m:576 Object request failed: Underlying HTTP request operation failed with error: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x9470aa0 {NSErrorFailingURLKey= https://myDomain.com/myRessource NSErrorFailingURLStringKey= https://myDomain.com/myRessource } 2013-10-31 11:52:12.921 myApp[87552:651b] E restkit.network:RKObjectRequestOperation.m:238 GET ' https://myDomain.com/myRessource ' (0/0 objects) [request=0.2065s mapping=0.0000s total=0.2130s]: error=Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x9470aa0 {NSErrorFailingURLKey= https://myDomain.com/myRessource , NSErrorFailingURLStringKey= https://myDomain.com/myRessource } response.body=(null)

問題:

  1. 是它正確的方式來初始化RestKit?我不想在每個請求中指定 SSL-stuff。它應該全局設置。
  2. 任何想法爲什麼請求失敗? body=null看起來很可疑。
+0

嗨,我在0.20.3中有相同的錯誤代碼1012,但是在我將RestKit更新爲0.22.0之後,它工作正常。 – Puttin

回答

1

在RKObjectManager,你會發現:

#ifdef AFNETWORKING_PIN_SSL_CERTIFICATES 
operation.SSLPinningMode = self.HTTPClient.defaultSSLPinningMode; 
#endif 

所以你需要設置,如果直接使用對象管理器定義。

相關問題