2013-03-06 149 views
0

我正在開發Objective-C中的一段代碼,用於更快地執行HTTP/HTTPS請求。該代碼將被插入包含最常見執行操作的庫中。我正在尋找一臺服務器,用來測試需要驗證的HTTPS請求。測試HTTPS身份驗證

特別是我看到,iOS標準庫的類NSURLConnection。 NSURLConnectionDelegate協議有方法連接:didReceiveAuthenticationChallenge: 這就是我想要用我的課程測試的內容。

有什麼嗎?我在谷歌搜索,但我什麼也沒找到。

回答

1

是的,你是對的,你將需要使用didReceiveAuthenticationChallengeNSURLConnectionDelegate這裏是一些使用例子

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { 
    return YES; 
} 
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { 
    [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; 
} 
+0

謝謝,但我在尋找一個服務器,通過它測試這些方法。 – Massimo 2013-03-06 12:05:50