Hi,
i am using self signed ssl certificate for my web site,
when i try to navigate my site page did not loaded,
when i searched from from web and found some solutions like :
https://stackoverflow.com/questions/11573164/uiwebview-to-view-self-signed-websites-no-private-api-not-nsurlconnection-i
in my code i overrided some methods like :
@Override public boolean webViewShouldStartLoadWithRequestNavigationType(UIWebView webView, NSURLRequest request, @NInt long navigationType) { if(!authenticated) { authRequest = request; NSURLConnection urlConnection = NSURLConnection.alloc().initWithRequestDelegate(request, this); urlConnection.start(); return false; } else { // write your method for this return true; } } @Override public boolean connectionCanAuthenticateAgainstProtectionSpace(NSURLConnection connection, NSURLProtectionSpace protectionSpace) { return protectionSpace.authenticationMethod().equals(Foundation.NSURLAuthenticationMethodServerTrust()); } @Override public void connectionDidReceiveAuthenticationChallenge(NSURLConnection connection, NSURLAuthenticationChallenge challenge) { if (challenge.previousFailureCount() == 0 && challenge.protectionSpace().authenticationMethod().equals(Foundation.NSURLAuthenticationMethodServerTrust())) { authenticated = true; NSURLCredential nsurlCredential = NSURLCredential.credentialForTrust(challenge.protectionSpace().serverTrust()); NSURL baseURL = NSURL.URLWithString("https://mydomain.com"); if (challenge.protectionSpace().host() .equals(baseURL.host())) { challenge.sender().useCredentialForAuthenticationChallenge(nsurlCredential,challenge); } } else challenge.sender().cancelAuthenticationChallenge(challenge); }
But it throws exception:
017-09-13 11:11:20.335 ios2[2561:48336] *** Terminating app due to uncaught exception ‘java.lang.IncompatibleClassChangeError’, reason: 'java.lang.IncompatibleClassChangeError: Class ‘apple.foundation.NSURLConnection’ does not implement interface ‘apple.foundation.protocol.NSURLAuthenticationChallengeSender’ in call to ‘void apple.foundation.protocol.NSURLAuthenticationChallengeSender.useCredentialForAuthenticationChallenge(apple.foundation.NSURLCredential, apple.foundation.NSURLAuthenticationChallenge)’
what is wrong with my code?
is that solution is right? if not is there alternative solutions ?
does apple accepts applications which try to connect http sites with self-signed ssl cert ?
Thanks.