Class TlsUtils


  • public final class TlsUtils
    extends Object
    Utility class for shared TLS configuration logic
    • Method Detail

      • extractTlsConfig

        public static TlsConfig extractTlsConfig​(PinotConfiguration pinotConfig,
                                                 String namespace)
        Extract a TlsConfig instance from a namespaced set of configuration keys.
        Parameters:
        pinotConfig - pinot configuration
        namespace - namespace prefix
        Returns:
        TlsConfig instance
      • extractTlsConfig

        public static TlsConfig extractTlsConfig​(PinotConfiguration pinotConfig,
                                                 String namespace,
                                                 TlsConfig defaultConfig)
        Extract a TlsConfig instance from a namespaced set of configuration keys, based on a default config
        Parameters:
        pinotConfig - pinot configuration
        namespace - namespace prefix
        defaultConfig - TLS config defaults
        Returns:
        TlsConfig instance
      • createKeyManagerFactory

        public static KeyManagerFactory createKeyManagerFactory​(TlsConfig tlsConfig)
        Create a KeyManagerFactory instance for a given TlsConfig
        Parameters:
        tlsConfig - TLS config
        Returns:
        KeyManagerFactory
      • createKeyManagerFactory

        public static KeyManagerFactory createKeyManagerFactory​(String keyStorePath,
                                                                String keyStorePassword,
                                                                String keyStoreType)
        Create a KeyManagerFactory instance for a given path and key password
        Parameters:
        keyStorePath - store path
        keyStorePassword - password
        keyStoreType - keystore type for keystore
        Returns:
        KeyManagerFactory
      • createTrustManagerFactory

        public static TrustManagerFactory createTrustManagerFactory​(TlsConfig tlsConfig)
        Create a TrustManagerFactory instance from a given TlsConfig.
        Parameters:
        tlsConfig - TLS config
        Returns:
        TrustManagerFactory
      • createTrustManagerFactory

        public static TrustManagerFactory createTrustManagerFactory​(String trustStorePath,
                                                                    String trustStorePassword,
                                                                    String trustStoreType)
        Create a TrustManagerFactory instance from a given path and key password
        Parameters:
        trustStorePath - store path
        trustStorePassword - password
        trustStoreType - keystore type for truststore
        Returns:
        TrustManagerFactory
      • installDefaultSSLSocketFactory

        public static void installDefaultSSLSocketFactory​(TlsConfig tlsConfig)
        Installs a default TLS socket factory for all HttpsURLConnection instances based on a given TlsConfig (1 or 2-way)
        Parameters:
        tlsConfig - TLS config
      • installDefaultSSLSocketFactory

        public static void installDefaultSSLSocketFactory​(String keyStoreType,
                                                          String keyStorePath,
                                                          String keyStorePassword,
                                                          String trustStoreType,
                                                          String trustStorePath,
                                                          String trustStorePassword)
        Installs a default TLS socket factory for all HttpsURLConnection instances based on a given set of key and trust store paths and passwords
        Parameters:
        keyStoreType - keystore type for keystore
        keyStorePath - key store path
        keyStorePassword - key password
        trustStoreType - keystore type for truststore
        trustStorePath - trust store path
        trustStorePassword - trust password
      • getSslContext

        public static SSLContext getSslContext()
        Get the SSL context, see: TlsUtils.SSLContextHolder for more details.
        Returns:
        the SSL context.
      • setSslContext

        public static void setSslContext​(SSLContext sslContext)
        Set the SSL context, see: TlsUtils.SSLContextHolder for more details.
        Parameters:
        sslContext - the SSL context to be set.
      • buildClientContext

        public static io.netty.handler.ssl.SslContext buildClientContext​(TlsConfig tlsConfig)
        Builds client side SslContext based on a given TlsConfig.
        Parameters:
        tlsConfig - TLS config
      • buildServerContext

        public static io.netty.handler.ssl.SslContext buildServerContext​(TlsConfig tlsConfig)
        Builds server side SslContext based on a given TlsConfig.
        Parameters:
        tlsConfig - TLS config