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.
- turned on "Allow Arbitrary Loads" to YES and added -
- Set the self.webView.navigationDelegate = self;
- 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!