diff --git a/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java b/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java index e41c49a..6905b2f 100644 --- a/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java +++ b/src/android/com/silkimen/cordovahttp/CordovaHttpBase.java @@ -8,7 +8,7 @@ import java.net.UnknownHostException; import java.nio.ByteBuffer; -import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLException; import com.silkimen.http.HttpBodyDecoder; import com.silkimen.http.HttpRequest; @@ -73,10 +73,10 @@ abstract class CordovaHttpBase implements Runnable { this.sendBody(request); this.processResponse(request, response); } catch (HttpRequestException e) { - if (e.getCause() instanceof SSLHandshakeException) { + if (e.getCause() instanceof SSLException) { response.setStatus(-2); - response.setErrorMessage("SSL handshake failed: " + e.getMessage()); - Log.w(TAG, "SSL handshake failed", e); + response.setErrorMessage("TLS connection could not be established: " + e.getMessage()); + Log.w(TAG, "TLS connection could not be established", e); } else if (e.getCause() instanceof UnknownHostException) { response.setStatus(-3); response.setErrorMessage("Host could not be resolved: " + e.getMessage()); diff --git a/src/ios/CordovaHttpPlugin.m b/src/ios/CordovaHttpPlugin.m index b23d3ad..60f2de1 100644 --- a/src/ios/CordovaHttpPlugin.m +++ b/src/ios/CordovaHttpPlugin.m @@ -106,8 +106,12 @@ case -1009: // no connection return [NSNumber numberWithInt:-6]; - case -1202: - // untrusted SSL certificate + case -1200: // secure connection failed + case -1201: // certificate has bad date + case -1202: // certificate untrusted + case -1203: // certificate has unknown root + case -1204: // certificate is not yet valid + // configuring SSL failed return [NSNumber numberWithInt:-2]; default: return [NSNumber numberWithInt:-1]; diff --git a/test/app-test-definitions.js b/test/app-test-definitions.js index 78801de..b791574 100644 --- a/test/app-test-definitions.js +++ b/test/app-test-definitions.js @@ -38,7 +38,7 @@ const helpers = { }; const messageFactory = { - sslTrustAnchor: function() { return 'SSL handshake failed: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.' }, + sslTrustAnchor: function() { return 'TLS connection could not be established: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.' }, invalidCertificate: function(domain) { return 'The certificate for this server is invalid. You might be connecting to a server that is pretending to be “' + domain + '” which could put your confidential information at risk.' } }