Class SslUtils

java.lang.Object
org.jmxtrans.embedded.util.net.ssl.SslUtils

public class SslUtils
extends Object
Author:
Cyrille Le Clerc
  • Method Details

    • getSSLSocketFactory

      @Nonnull public static SSLSocketFactory getSSLSocketFactory​(@Nullable String keyStore, @Nullable String keyStorePassword, @Nullable String trustStore, @Nullable String trustStorePassword)
      Build an SSLSocketFactory with the given trust store and key store.
      Parameters:
      keyStore - path to the given JKS key store. Can be a classpath resource ("classpath:com/example/keystore.jks") of file system related. Optional, if {code null}, then the JVM key store is used.
      keyStorePassword - password to open the key store
      trustStore - path to the given JKS trust store. Can be a classpath resource ("classpath:com/example/keystore.jks") of file system related. Optional, if {code null}, then the JVM key store is used.
      trustStorePassword - password to open the trust store
      Returns:
      the SSLSocketFactory
    • getSslContext

      @Nonnull public static SSLContext getSslContext​(@Nullable String keyStore, @Nullable String keyStorePassword, @Nullable String trustStore, @Nullable String trustStorePassword)
      Build an SSLContext with the given trust store and key store.
      Parameters:
      keyStore - path to the given JKS key store. Can be a classpath resource ("classpath:com/example/keystore.jks") of file system related. Optional, if {code null}, then the JVM key store is used.
      keyStorePassword - password to open the key store
      trustStore - path to the given JKS trust store. Can be a classpath resource ("classpath:com/example/truststore.jks") of file system related. Optional, if {code null}, then the JVM key store is used.
      trustStorePassword - password to open the trust store
      Returns:
      the SSLContext
    • getTrustAllSSLSocketFactory

      @Nonnull public static SSLSocketFactory getTrustAllSSLSocketFactory()
      Build an SSLSocketFactory that trusts all the X509 certificates.
      Returns:
      the created SSLSocketFactory