2011-06-10 18 views
7

私はiPhoneプログラミングを開始します。私は解決できない大きな問題があります。だから、UIWebViewでHTTPS URLをロード

、私はUIWebviewを持って、私は問題なくHTTP URLを読み込むことができます。

NSString urlAdress; 
urlAdress = @"http://servername"; 
NSURL *url = [NSURL URLWithString:urlAdress]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[webView loadRequest:requestObj]; 

その作業を、マイページのロードが私のUIWebViewであるが、私は交換するとき:

urlAdress = @"http://servername"; 

によって

urlAdress = @"https://servername"; 

私は空白の画面があります。

私はそれを読んでいますが、私のwebviewにhttps urlをロードする簡単な方法はありますか?
私は約ASIHTTPRequestを読んだが、私はそれを実装するために到着しませんでした。

ロードするだけですHTTPS URL

+0

あなたが 'httpsを読み込む場合はどうなりますか:Safariで// servername'を? – deanWombourne

+0

サファリで「http:// servername」と「https:// servername」の両方をロードできます – Borneto

+1

これは自己署名証明書ですか? – Jim

答えて

6

はこれを試してみてください:

- (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]; 
} 
+1

これをUIWebViewを含むUIViewControllerに追加するだけですか?私はこれでどうしたらいいのか分かりません。 – powerj1984

+1

これらの2つのメソッドは、[NSURLConnectionDelegate](https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html)プロトコルの一部であるため、 NSURLConnectionの代理人として動作しています。 –

+0

私は自己割り当ての証明書も使用していましたが、上記の実装と連携して動作しました。 – m4n1c

関連する問題