merged Android - Load client certificate from local storage
This commit is contained in:
parent
596a228a05
commit
0a49c7094f
@ -40,6 +40,7 @@
|
||||
- Merged "Fix RangeError: Maximum call stack size exceeded" [#1208](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1208) (thanks to [liasica](https://github.com/liasica))
|
||||
- Merged "fix: try to open with Chrome if default browser app does not support custom tabs" [#1233](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1233) (thanks to [addie9000](https://github.com/addie9000))
|
||||
- Merged "fix: Prevent Android java.lang.NullPointerException in InAppWebViewCl…" [#1237](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1237) (thanks to [kamilpowalowski](https://github.com/kamilpowalowski))
|
||||
- Merged "Android - Load client certificate from local storage" [#1241](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1241) (thanks to [akioyamamoto1977](https://github.com/akioyamamoto1977))
|
||||
|
||||
## 5.4.4+3
|
||||
|
||||
|
@ -21,6 +21,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -110,17 +111,23 @@ public class Util {
|
||||
@Nullable String certificatePassword,
|
||||
@NonNull String keyStoreType) {
|
||||
PrivateKeyAndCertificates privateKeyAndCertificates = null;
|
||||
InputStream certificateFileStream = null;
|
||||
|
||||
try {
|
||||
InputStream certificateFileStream = getFileAsset(plugin, certificatePath);
|
||||
certificateFileStream = getFileAsset(plugin, certificatePath);
|
||||
} catch (IOException ignored) {}
|
||||
|
||||
try {
|
||||
if (certificateFileStream == null) {
|
||||
certificateFileStream = new FileInputStream(certificatePath);
|
||||
}
|
||||
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
|
||||
keyStore.load(certificateFileStream, certificatePassword != null ? certificatePassword.toCharArray() : null);
|
||||
keyStore.load(certificateFileStream, (certificatePassword != null ? certificatePassword : "").toCharArray());
|
||||
|
||||
Enumeration<String> aliases = keyStore.aliases();
|
||||
String alias = aliases.nextElement();
|
||||
|
||||
Key key = keyStore.getKey(alias, certificatePassword != null ? certificatePassword.toCharArray() : null);
|
||||
Key key = keyStore.getKey(alias, (certificatePassword != null ? certificatePassword : "").toCharArray());
|
||||
if (key instanceof PrivateKey) {
|
||||
PrivateKey privateKey = (PrivateKey)key;
|
||||
Certificate cert = keyStore.getCertificate(alias);
|
||||
@ -132,6 +139,15 @@ public class Util {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
} finally {
|
||||
if (certificateFileStream != null) {
|
||||
try {
|
||||
certificateFileStream.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
Log.e(LOG_TAG, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return privateKeyAndCertificates;
|
||||
|
Loading…
x
Reference in New Issue
Block a user