diff --git a/src/android/com/silkimen/cordovahttp/CordovaServerTrust.java b/src/android/com/silkimen/cordovahttp/CordovaServerTrust.java index 822079e..5e97364 100644 --- a/src/android/com/silkimen/cordovahttp/CordovaServerTrust.java +++ b/src/android/com/silkimen/cordovahttp/CordovaServerTrust.java @@ -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);