0

There is a similar question written - Allow unverified ssl certificates in WKWebView Added comments and asked question on that one and no-one answered. So trying to post the question again. Issue is - Trying to load a HTTPS url with a self-signed certificate in a WKWebView for iOS 16, Xcode 14.2 and it keeps failing.

I do not need a solution that is valid for AppStore, as I only need to access self-signed certificate sites on development phases, not on production, but it's really a problem for development and testing server instances.

Followed the suggested answer in Allow unverified ssl certificates in WKWebView.

  1. turned on "Allow Arbitrary Loads" to YES and added -
  2. Set the self.webView.navigationDelegate = self;
  3. added didReceiveAuthenticationChallenge
  • (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; CFDataRef exceptions = SecTrustCopyExceptions(serverTrust); SecTrustSetExceptions(serverTrust, exceptions); CFRelease(exceptions);

    completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:serverTrust]); }

Problem is that It is not being called! Any help is appreciated!

  • Can I use any other container/control if not WKWebView, to display Unverified Urls. Any help is appreciated. Thank you. – user1664018 Mar 14 '23 at 14:40
  • Work around - Download/save the cert on device in 'files', install it, trust the certificate then go to Certificate Trust settings and enable full trust for root certificates. You should be good now. This is just for dev testing and nothing to do with production releases. Hope will help and save some time for others. – user1664018 Apr 26 '23 at 15:46

0 Answers0