简体   繁体   中英

HTTPS call not going in Cordova android release apk

I am unable to post an HTTPs call in android release apk. I have an android app which makes a https call for login, the request does not even reach the server. However it works in the debug apk version(http). The server logs not showing any error or warnings since the request itself doesn't reach the server. The apk is signed with the actual SHA certificate that is used to host the domain.

    loginHandler(value) {
    this.loader.display(true);  


        if (isNaN(value.email)) {
            value.email = value.email.toLowerCase();

        }
        else {
            value.email = value.email;

        }
        var loginValue = {
            'username': value.email,
            'password': value.password
        }


        this.loginService.loginService(loginValue)
        .subscribe(res => {
            this.loader.display(false);

            this.message = '';
            if (res.response.status === 'Success') {                    

            } else {
                this.errorMessage = res.response.validation;
                this.errorMessage == 'Email not verified. Please check your email.' 
                                        ? this.showResendVerification = true 
                                        : this.showResendVerification = false;
            }
            if (res.response.validation == "Email or phone number not verified.")
            {
                this.OTPHandler(value);
                this.router.navigate(['/otp-verification']);
            }
        });
}

In debug build of cordova android apps, SSL errors are ignored so you can access to any server event if there is no certificate or a bad certificate (for example a dev server).

It behaves diferrently for release build, https connections will fail if the server has :

  • no SSL certificate
  • a self-signed certificate
  • a certificate delivered from an autority that is not trusted by the device
  • a certificate delivered for a server/url different from the one you are trying to access.

To be sure, you should try to open the browser on the device and open the https url you use in your app. If you get a warning about security, you will know there's an issue with the server certificate.

You can also try to patch the cordova sources so the ssl errors are not ignored even in debug see this post . (then your ssl calls should fail even in debug)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM