remove explicit host name verification setting on Android

This commit is contained in:
Sefa Ilkimen
2018-05-25 18:45:10 +02:00
parent 2ae4c7cf39
commit 8e4bfdbc70
2 changed files with 3 additions and 17 deletions
@@ -302,10 +302,13 @@ public class HttpRequest {
try {
if (mode == CERT_MODE_TRUSTALL) {
SOCKET_FACTORY = createSocketFactory(getNoopTrustManagers());
HOSTNAME_VERIFIER = getTrustedVerifier();
} else if (mode == CERT_MODE_PINNED) {
SOCKET_FACTORY = createSocketFactory(getPinnedTrustManagers());
HOSTNAME_VERIFIER = null;
} else {
SOCKET_FACTORY = null;
HOSTNAME_VERIFIER = null;
}
CURRENT_CERT_MODE = mode;
@@ -314,19 +317,6 @@ public class HttpRequest {
}
}
/**
* Configure host name verification for all future HTTPS connections
*
* @param enabled
*/
public static void setHostnameVerification(boolean enabled) {
if (enabled) {
HOSTNAME_VERIFIER = null;
} else {
HOSTNAME_VERIFIER = getTrustedVerifier();
}
}
private static TrustManager[] getPinnedTrustManagers() throws IOException {
if (PINNED_CERTS == null) {
throw new IOException("You must add at least 1 certificate in order to pin to certificates");
@@ -100,10 +100,8 @@ public class CordovaHttpPlugin extends CordovaPlugin {
if (accept) {
HttpRequest.setSSLCertMode(HttpRequest.CERT_MODE_TRUSTALL);
HttpRequest.setHostnameVerification(false);
} else {
HttpRequest.setSSLCertMode(HttpRequest.CERT_MODE_DEFAULT);
HttpRequest.setHostnameVerification(true);
}
callbackContext.success();
@@ -169,10 +167,8 @@ public class CordovaHttpPlugin extends CordovaPlugin {
}
HttpRequest.setSSLCertMode(HttpRequest.CERT_MODE_PINNED);
HttpRequest.setHostnameVerification(true);
} else {
HttpRequest.setSSLCertMode(HttpRequest.CERT_MODE_DEFAULT);
HttpRequest.setHostnameVerification(true);
}
}
}