Fix #189: error code mappings for TLS handshake problems are not precise

This commit is contained in:
Sefa Ilkimen
2019-04-08 17:58:39 +02:00
parent e1e720fe2d
commit 56f8b41f4f
3 changed files with 11 additions and 7 deletions
@@ -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());
+6 -2
View File
@@ -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];
+1 -1
View File
@@ -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.' }
}