Last active
December 13, 2022 05:10
-
-
Save sandipchitale/a7d47600eb5c314947bae6a96f1cc171 to your computer and use it in GitHub Desktop.
Get default trust materia #javax-ssl-truststore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.KeyStore; | |
import java.security.cert.X509Certificate; | |
import javax.net.ssl.TrustManager; | |
import javax.net.ssl.TrustManagerFactory; | |
import javax.net.ssl.X509TrustManager; | |
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); | |
tmf.init((KeyStore) null); | |
for (TrustManager tm : tmf.getTrustManagers()) { | |
if (tm instanceof X509TrustManager) { | |
X509TrustManager xtm = (X509TrustManager) tm; | |
for (X509Certificate x509c : xtm.getAcceptedIssuers()) { | |
System.out.println(x509c.getSubjectX500Principal().getName()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment