mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-04-24 00:00:03 +08:00
Merge branch 'master' into ios-networking-indicator
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user