mirror of
https://github.com/silkimen/cordova-plugin-advanced-http.git
synced 2026-01-31 00:00:03 +08:00
use the correct asset dir based on we are running on capacitor or cordova
This commit is contained in:
@@ -71,7 +71,7 @@ class CordovaServerTrust implements Runnable {
|
||||
this.tlsConfiguration.setTrustManagers(this.noOpTrustManagers);
|
||||
} else if ("pinned".equals(this.mode)) {
|
||||
this.tlsConfiguration.setHostnameVerifier(null);
|
||||
this.tlsConfiguration.setTrustManagers(this.getTrustManagers(this.getCertsFromBundle("www/certificates")));
|
||||
this.tlsConfiguration.setTrustManagers(this.getTrustManagers(this.getCertsFromBundle(getWebAssetDir() + "/certificates")));
|
||||
} else {
|
||||
this.tlsConfiguration.setHostnameVerifier(null);
|
||||
this.tlsConfiguration.setTrustManagers(this.getTrustManagers(this.getCertsFromKeyStore("AndroidCAStore")));
|
||||
@@ -84,6 +84,14 @@ class CordovaServerTrust implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private String getWebAssetDir() {
|
||||
return isRunningOnCapacitor()? "public" : "www";
|
||||
}
|
||||
|
||||
private boolean isRunningOnCapacitor() {
|
||||
return this.activity.getClass().getSuperclass().getName().contains("com.getcapacitor");
|
||||
}
|
||||
|
||||
private TrustManager[] getTrustManagers(KeyStore store) throws GeneralSecurityException {
|
||||
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
|
||||
|
||||
Reference in New Issue
Block a user