Class SSLHostConfigCertificate

  • All Implemented Interfaces:
    java.io.Serializable

    public class SSLHostConfigCertificate
    extends java.lang.Object
    implements java.io.Serializable
    Represents the SSL certificate configuration for a virtual host. Holds the certificate details for either JSSE or OpenSSL implementations.
    See Also:
    Serialized Form
    • Field Detail

    • Constructor Detail

      • SSLHostConfigCertificate

        public SSLHostConfigCertificate()
        Creates a new certificate configuration with default settings.
      • SSLHostConfigCertificate

        public SSLHostConfigCertificate​(SSLHostConfig sslHostConfig,
                                        SSLHostConfigCertificate.Type type)
        Creates a new certificate configuration for the given host and type.
        Parameters:
        sslHostConfig - the parent SSL host configuration
        type - the type of this certificate
    • Method Detail

      • getSslContext

        public SSLContext getSslContext()
        Returns the SSLContext for this certificate. Returns the provided context if set, otherwise returns the generated context.
        Returns:
        the SSLContext instance
      • setSslContext

        public void setSslContext​(SSLContext sslContext)
        Sets the provided SSLContext for this certificate configuration.
        Parameters:
        sslContext - the SSLContext to use
      • getSslContextGenerated

        public SSLContext getSslContextGenerated()
        Returns the SSLContext generated from the certificate configuration.
        Returns:
        the generated SSLContext, or null if not yet generated
      • getSSLHostConfig

        public SSLHostConfig getSSLHostConfig()
        Returns the SSLHostConfig that owns this certificate configuration.
        Returns:
        the parent SSLHostConfig
      • getObjectName

        public javax.management.ObjectName getObjectName()
        Returns the JMX ObjectName for this certificate configuration.
        Returns:
        the JMX ObjectName
      • setObjectName

        public void setObjectName​(javax.management.ObjectName oname)
        Sets the JMX ObjectName for this certificate configuration.
        Parameters:
        oname - the JMX ObjectName
      • chooseServerAlias

        public java.lang.String chooseServerAlias​(javax.net.ssl.X509KeyManager keyManager)
        Returns the alias the given key manager would choose to serve for this certificate, or null if it has no suitable entry. When getType() is SSLHostConfigCertificate.Type.UNDEFINED every key type is tried. For a key manager that Tomcat has pinned to an alias this is the alias used in every handshake, which can differ from getCertificateKeyAlias() - for example after the SunMSCAPI Windows-MY numbered-duplicate resolution performed by SSLUtilBase#getKeyManagers(). Other key managers may choose differently in a handshake, for example depending on the negotiated key type or the requested server name.
        Parameters:
        keyManager - the key manager that will serve this certificate
        Returns:
        the served alias, or null if the key manager has no suitable entry
      • getCertificateKeyPassword

        public java.lang.String getCertificateKeyPassword()
        Returns the password for the certificate's private key.
        Returns:
        the certificate key password
      • setCertificateKeyPassword

        public void setCertificateKeyPassword​(java.lang.String certificateKeyPassword)
        Sets the password for the certificate's private key.
        Parameters:
        certificateKeyPassword - the certificate key password
      • getCertificateKeyPasswordFile

        public java.lang.String getCertificateKeyPasswordFile()
        Returns the path to the file containing the certificate key password.
        Returns:
        the key password file path
      • setCertificateKeyPasswordFile

        public void setCertificateKeyPasswordFile​(java.lang.String certificateKeyPasswordFile)
        Sets the path to the file containing the certificate key password.
        Parameters:
        certificateKeyPasswordFile - the key password file path
      • setCertificateKeyAlias

        public void setCertificateKeyAlias​(java.lang.String certificateKeyAlias)
        Sets the alias of the key entry in the keystore.
        Parameters:
        certificateKeyAlias - the key alias
      • getCertificateKeyAlias

        public java.lang.String getCertificateKeyAlias()
        Returns the alias of the key entry in the keystore.
        Returns:
        the key alias
      • getCertificateKeyAliasOrDefault

        public java.lang.String getCertificateKeyAliasOrDefault()
        Returns the configured key alias or, if none is configured, SSLUtilBase.DEFAULT_KEY_ALIAS.
        Returns:
        the configured or default key alias, never null
      • setCertificateKeystoreFile

        public void setCertificateKeystoreFile​(java.lang.String certificateKeystoreFile)
        Sets the path to the keystore file.
        Parameters:
        certificateKeystoreFile - the keystore file path
      • getCertificateKeystoreFile

        public java.lang.String getCertificateKeystoreFile()
        Returns the path to the keystore file.
        Returns:
        the keystore file path
      • setCertificateKeystorePassword

        public void setCertificateKeystorePassword​(java.lang.String certificateKeystorePassword)
        Sets the password used to access the keystore.
        Parameters:
        certificateKeystorePassword - the keystore password
      • getCertificateKeystorePassword

        public java.lang.String getCertificateKeystorePassword()
        Returns the password used to access the keystore.
        Returns:
        the keystore password
      • setCertificateKeystorePasswordFile

        public void setCertificateKeystorePasswordFile​(java.lang.String certificateKeystorePasswordFile)
        Sets the path to the file containing the keystore password.
        Parameters:
        certificateKeystorePasswordFile - the keystore password file path
      • getCertificateKeystorePasswordFile

        public java.lang.String getCertificateKeystorePasswordFile()
        Returns the path to the file containing the keystore password.
        Returns:
        the keystore password file path
      • setCertificateKeystoreProvider

        public void setCertificateKeystoreProvider​(java.lang.String certificateKeystoreProvider)
        Sets the provider of the keystore.
        Parameters:
        certificateKeystoreProvider - the keystore provider name
      • getCertificateKeystoreProvider

        public java.lang.String getCertificateKeystoreProvider()
        Returns the provider of the keystore.
        Returns:
        the keystore provider name
      • setCertificateKeystoreType

        public void setCertificateKeystoreType​(java.lang.String certificateKeystoreType)
        Sets the type of the keystore (e.g., JKS, PKCS12).
        Parameters:
        certificateKeystoreType - the keystore type
      • getCertificateKeystoreType

        public java.lang.String getCertificateKeystoreType()
        Returns the type of the keystore (e.g., JKS, PKCS12).
        Returns:
        the keystore type
      • setCertificateKeystore

        public void setCertificateKeystore​(java.security.KeyStore certificateKeystore)
        Sets the Java KeyStore for this certificate.
        Parameters:
        certificateKeystore - the KeyStore instance
      • getCertificateKeystore

        public java.security.KeyStore getCertificateKeystore()
                                                      throws java.io.IOException
        Returns the Java KeyStore for this certificate. If not previously set, loads it from the configured keystore file.
        Returns:
        the KeyStore instance
        Throws:
        java.io.IOException - if the keystore cannot be loaded
      • setCertificateKeyManager

        public void setCertificateKeyManager​(javax.net.ssl.X509KeyManager certificateKeyManager)
        Sets the X509KeyManager for this certificate configuration.
        Parameters:
        certificateKeyManager - the X509KeyManager instance
      • getCertificateKeyManager

        public javax.net.ssl.X509KeyManager getCertificateKeyManager()
        Returns the X509KeyManager for this certificate configuration.
        Returns:
        the X509KeyManager instance
      • setCertificateChainFile

        public void setCertificateChainFile​(java.lang.String certificateChainFile)
        Sets the path to the certificate chain file used by OpenSSL.
        Parameters:
        certificateChainFile - the path to the certificate chain file
      • getCertificateChainFile

        public java.lang.String getCertificateChainFile()
        Returns the path to the certificate chain file used by OpenSSL.
        Returns:
        the certificate chain file path
      • setCertificateFile

        public void setCertificateFile​(java.lang.String certificateFile)
        Sets the path to the certificate file used by OpenSSL.
        Parameters:
        certificateFile - the path to the certificate file
      • getCertificateFile

        public java.lang.String getCertificateFile()
        Returns the path to the certificate file used by OpenSSL.
        Returns:
        the certificate file path
      • setCertificateKeyFile

        public void setCertificateKeyFile​(java.lang.String certificateKeyFile)
        Sets the path to the private key file used by OpenSSL.
        Parameters:
        certificateKeyFile - the path to the private key file
      • getCertificateKeyFile

        public java.lang.String getCertificateKeyFile()
        Returns the path to the private key file used by OpenSSL.
        Returns:
        the private key file path