use the correct asset dir based on we are running on capacitor or cordova

This commit is contained in:
uf200387
2023-03-05 00:13:06 +08:00
parent 469ace48b5
commit 0c26ada847

View File

@@ -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);