Class TlsConfigHelper

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.net.ssl.X509KeyManager keyManager  
      private javax.net.ssl.SSLContext sslContext  
      private javax.net.ssl.X509TrustManager trustManager  
    • Constructor Summary

      Constructors 
      Constructor Description
      TlsConfigHelper()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TlsConfigHelper copy()
      Return a shallow copy of this instance.
      javax.net.ssl.X509KeyManager getKeyManager()
      Get the X509KeyManager.
      javax.net.ssl.SSLContext getSslContext()
      Get the SSLContext.
      javax.net.ssl.X509TrustManager getTrustManager()
      Get the X509TrustManager.
      void setKeyManagerFromCerts​(byte[] privateKeyPem, byte[] certificatePem)
      Configure the X509KeyManager from the given private key and certificate, both in PEM format.
      void setSslContext​(javax.net.ssl.SSLContext sslContext, javax.net.ssl.X509TrustManager trustManager)
      Configure the SSLContext and X509TrustManager.
      void setTrustManagerFromCerts​(byte[] trustedCertsPem)
      Configure the X509TrustManager from the given cert content.
      • Methods inherited from class java.lang.Object

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

      • keyManager

        @Nullable
        private javax.net.ssl.X509KeyManager keyManager
      • trustManager

        @Nullable
        private javax.net.ssl.X509TrustManager trustManager
      • sslContext

        @Nullable
        private javax.net.ssl.SSLContext sslContext
    • Constructor Detail

      • TlsConfigHelper

        public TlsConfigHelper()
    • Method Detail

      • setTrustManagerFromCerts

        public void setTrustManagerFromCerts​(byte[] trustedCertsPem)
        Configure the X509TrustManager from the given cert content.

        Must not be called multiple times, or if setSslContext(SSLContext, X509TrustManager) has been previously called.

        Parameters:
        trustedCertsPem - Certificate in PEM format.
      • setKeyManagerFromCerts

        public void setKeyManagerFromCerts​(byte[] privateKeyPem,
                                           byte[] certificatePem)
        Configure the X509KeyManager from the given private key and certificate, both in PEM format.

        Must not be called multiple times, or if setSslContext(SSLContext, X509TrustManager) has been previously called.

        Parameters:
        privateKeyPem - Private key content in PEM format.
        certificatePem - Certificate content in PEM format.
      • setSslContext

        public void setSslContext​(javax.net.ssl.SSLContext sslContext,
                                  javax.net.ssl.X509TrustManager trustManager)
        Configure the SSLContext and X509TrustManager.

        Must not be called multiple times, or if setTrustManagerFromCerts(byte[]) or setKeyManagerFromCerts(byte[], byte[]) has been previously called.

        Parameters:
        sslContext - the SSL context.
        trustManager - the trust manager.
      • getKeyManager

        @Nullable
        public javax.net.ssl.X509KeyManager getKeyManager()
        Get the X509KeyManager.
      • getTrustManager

        @Nullable
        public javax.net.ssl.X509TrustManager getTrustManager()
        Get the X509TrustManager.
      • getSslContext

        @Nullable
        public javax.net.ssl.SSLContext getSslContext()
        Get the SSLContext.
      • copy

        public TlsConfigHelper copy()
        Return a shallow copy of this instance.