Skip to content

Commit 1cf20ff

Browse files
author
Lauri Wiljami Ahonen
committed
Use Windows system certificate store if requested by system properties
1 parent d0c6f63 commit 1cf20ff

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

client/src/main/java/org/glassfish/tyrus/client/SslContextConfigurator.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,17 @@ public SSLContext createSSLContext() {
578578
TrustManagerFactory trustManagerFactory = null;
579579
KeyManagerFactory keyManagerFactory = null;
580580

581+
if ("SunMSCAPI".equals(System.getProperty(TRUST_STORE_PROVIDER))) {
582+
try {
583+
KeyStore keyStore = KeyStore.getInstance(System.getProperty(TRUST_STORE_TYPE), "SunMSCAPI");
584+
keyStore.load(null, null);
585+
trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
586+
trustManagerFactory.init(keyStore);
587+
} catch (Throwable e) {
588+
throw new RuntimeException(e);
589+
}
590+
}
591+
581592
if (keyStoreBytes != null || keyStoreFile != null) {
582593
try {
583594
KeyStore keyStore;

containers/jdk-client/src/main/java/org/glassfish/tyrus/container/jdk/client/SslContextConfigurator.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,17 @@ public SSLContext createSSLContext() {
524524

525525
try {
526526
TrustManagerFactory trustManagerFactory = null;
527+
if ("SunMSCAPI".equals(System.getProperty(TRUST_STORE_PROVIDER))) {
528+
try {
529+
KeyStore keyStore = KeyStore.getInstance(System.getProperty(TRUST_STORE_TYPE), "SunMSCAPI");
530+
keyStore.load(null, null);
531+
trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
532+
trustManagerFactory.init(keyStore);
533+
} catch (Throwable e) {
534+
throw new RuntimeException(e);
535+
}
536+
}
537+
527538
KeyManagerFactory keyManagerFactory = null;
528539

529540
if (keyStoreBytes != null || keyStoreFile != null) {

0 commit comments

Comments
 (0)