gree / unity-webview

zlib License
2.24k stars 684 forks source link

ignore the certificate checking on Unity Editor #1032

Closed marcolau0212 closed 7 months ago

marcolau0212 commented 7 months ago

when I'm developing my website and trying to debug on Unity Editor, the "CallOnError" event catch the error "Error Domain=NSURLErrorDomain Code=-1202 " The certificate for this server is invalid. You might be connecting to a server that is pretending to be “” which could put your confidential information at risk."

I understand that is because the certificate is outdate or somthing else cause this. What I want to know is how to ignore the certificate checking on Unity Editor

I know that I can modify the "Webview.mm" in the "Plugins/iOS" to ignore the certificate checking. But it only effect when I build the project

- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler
{
    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {

        NSURLCredential *card = [[NSURLCredential alloc]initWithTrust:challenge.protectionSpace.serverTrust];

        completionHandler(NSURLSessionAuthChallengeUseCredential,card);

    }
}
KojiNakamaru commented 7 months ago

You can find source code for WebView.bundle under https://github.com/gree/unity-webview/tree/09f19253c12e6e817ae492fb1ea2c2f1f53964a0/plugins/Mac .

marcolau0212 commented 7 months ago

Great! Thanks for your help ; )