Skip to content

Commit

Permalink
Use Windows system certificate store if requested by system properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauri Wiljami Ahonen committed Sep 23, 2024
1 parent d0c6f63 commit 87d4096
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,17 @@ public SSLContext createSSLContext() {
TrustManagerFactory trustManagerFactory = null;
KeyManagerFactory keyManagerFactory = null;

if ("SunMSCAPI".equals(System.getProperty(TRUST_STORE_PROVIDER))) {
try {
KeyStore keyStore = KeyStore.getInstance(System.getProperty(TRUST_STORE_TYPE), "SunMSCAPI");
keyStore.load(null, null);
trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keyStore);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}

if (keyStoreBytes != null || keyStoreFile != null) {
try {
KeyStore keyStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@ public SSLContext createSSLContext() {

try {
TrustManagerFactory trustManagerFactory = null;
if ("SunMSCAPI".equals(System.getProperty(TRUST_STORE_PROVIDER))) {
try {
KeyStore keyStore = KeyStore.getInstance(System.getProperty(TRUST_STORE_TYPE), "SunMSCAPI");
keyStore.load(null, null);
trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keyStore);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}

KeyManagerFactory keyManagerFactory = null;

if (keyStoreBytes != null || keyStoreFile != null) {
Expand Down

0 comments on commit 87d4096

Please sign in to comment.