Self Signed Ssl Cert Problem

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.

Dear @kurul

Follow this link

Regards,
Saeed.

that link solves http call via httpclient,
but what if UIWebView component ?
i mean can we navigate that url with UIWebView ?

visit this link too.

You only need to write this code in objective-c.
Hope your doing your best.

Dear saeed,

i re-write that code in java, i am using moe-1.2+ but in the method below exception occurs:

@Override
public void connectionWillSendRequestForAuthenticationChallenge(NSURLConnection connection, NSURLAuthenticationChallenge challenge) {

challenge.sender().useCredentialForAuthenticationChallenge(NSURLCredential.credentialForTrust(challenge.protectionSpace().serverTrust()),challenge);
challenge.sender().continueWithoutCredentialForAuthenticationChallenge(challenge);

}

exception:

2017-09-13 15:33:35.790 ios2[5383:119873] *** 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)’

Dear Kurul,

Could you please check with the latest 1.3.12 moe-gradle setting?

Best Regards,
Gergely