Class CertificateUtilities


  • public class CertificateUtilities
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.security.KeyStore getLoadedKeyStore​(java.lang.String javaHome)
      Returns a KeyStore that is loaded from the supplied java home.
      static javax.net.ssl.TrustManager[] getTrustManagers()  
      static void injectDefaultSslContext()
      Creates an SSLContext which is backed by a TrustManagerFactory whose Keystore contains the contents of the default keystore on disk as well as the certificates in the getCertificatesDirectory() and sets that SSLContext as the default.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getTrustManagers

        public static javax.net.ssl.TrustManager[] getTrustManagers()
                                                             throws java.security.NoSuchAlgorithmException,
                                                                    java.security.KeyStoreException
        Returns:
        the trust managers created from a trust manager factory initialized with the trust store loaded from java.home system property
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
        See Also:
        getLoadedKeyStore(String)
      • injectDefaultSslContext

        public static void injectDefaultSslContext()
                                            throws java.security.KeyStoreException,
                                                   java.security.NoSuchAlgorithmException,
                                                   java.security.KeyManagementException
        Creates an SSLContext which is backed by a TrustManagerFactory whose Keystore contains the contents of the default keystore on disk as well as the certificates in the getCertificatesDirectory() and sets that SSLContext as the default.
        Throws:
        java.security.KeyStoreException
        java.security.NoSuchAlgorithmException
        java.security.KeyManagementException
      • getLoadedKeyStore

        public static java.security.KeyStore getLoadedKeyStore​(java.lang.String javaHome)
        Returns a KeyStore that is loaded from the supplied java home. May be null if there was an issue loading the cacerts or default trust file file. If it has been previously loaded the existing KEY_STORE is returned.

        The default trust store is retrieved via getDefaultTrustStore(String)

        Parameters:
        javaHome - The path to java home. This is usually just the System Property 'java.home'. Must not be null.