Uploaded image for project: 'Appcelerator Modules'
  1. Appcelerator Modules
  2. MOD-2295

Appcelerator HTTPS module not working with android device

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: https 1.1.4
    • Component/s: Https
    • Environment:

      Ti : 5.0.9
      Appc : 5.4.0
      NPM : 2.11.3
      Alloy : 1.7.16
      TiSDK : 5.4.0
      Android Device : 5.1.1 Moto G
      Appc Studio : 4.7.0.201607130543

    • Sprint:
      2016 Sprint 21 SDK

      Description

      Sub : Appcelrator HTTPS module error.
      I have written code for iOS certification pinning its working perfect.
      Now I run same code on android device but it goes in XHR error every time .
      Below is code and error description.

              if (url.indexOf("SSOURL") > -1) {
                  var httpsCertificate = Alloy.CFG.STS_CERTIFICATE;
              } else {
                  var httpsCertificate = Alloy.CFG.REST_CERTIFICATE;
              }
       
      	Ti.API.info('Certificate >>'+httpsCertificate);
      	
          var securityManager = https.createX509CertificatePinningSecurityManager([{
              url : url,
              serverCertificate : httpsCertificate
          }]);
      	if (Ti.Network.online) {
      		var xhr = Ti.Network.createHTTPClient({
      			timeout : 40000,
      			securityManager: securityManager
      		});
      		xhr.open(method, url);
      }
      

      [ERROR] : TiHTTPClient: (TiHttpClient-3) [29516,35410] HTTP Error (javax.net.ssl.SSLHandshakeException): Leaf certificate could not be verified with provided public key
      [ERROR] : TiHTTPClient: javax.net.ssl.SSLHandshakeException: Leaf certificate could not be verified with provided public key
      [ERROR] : TiHTTPClient: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:322)
      [ERROR] : TiHTTPClient: at com.android.okhttp.Connection.upgradeToTls(Connection.java:201)
      [ERROR] : TiHTTPClient: at com.android.okhttp.Connection.connect(Connection.java:155)
      [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276)
      [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
      [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
      [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
      [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:217)
      [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
      [ERROR] : TiHTTPClient: at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:25)
      [ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1146)
      [ERROR] : TiHTTPClient: at java.lang.Thread.run(Thread.java:818)
      [ERROR] : TiHTTPClient: Caused by: java.security.cert.CertificateException: Leaf certificate could not be verified with provided public key
      [ERROR] : TiHTTPClient: at appcelerator.https.PinningTrustManager.checkServerTrusted(PinningTrustManager.java:84)
      [ERROR] : TiHTTPClient: at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:116)
      [ERROR] : TiHTTPClient: at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:550)
      [ERROR] : TiHTTPClient: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
      [ERROR] : TiHTTPClient: at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:318)
      [ERROR] : TiHTTPClient: ... 11 more

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cwilliams Christopher Williams
                Reporter:
                jnj.idr@gmail.com jayesh joshi
                Reviewer:
                Gary Mathews
              • Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code