Class SSLHostConfigCertificate

java.lang.Object
org.apache.tomcat.util.net.SSLHostConfigCertificate
All Implemented Interfaces:
Serializable

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

  • Constructor Details

    • 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 Details

    • 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 ObjectName getObjectName()
      Returns the JMX ObjectName for this certificate configuration.
      Returns:
      the JMX ObjectName
    • setObjectName

      public void setObjectName(ObjectName oname)
      Sets the JMX ObjectName for this certificate configuration.
      Parameters:
      oname - the JMX ObjectName
    • getType

      Returns the type of this certificate configuration.
      Returns:
      the certificate type
    • chooseServerAlias

      public String chooseServerAlias(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 String getCertificateKeyPassword()
      Returns the password for the certificate's private key.
      Returns:
      the certificate key password
    • setCertificateKeyPassword

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

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

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

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

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

      public 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(String certificateKeystoreFile)
      Sets the path to the keystore file.
      Parameters:
      certificateKeystoreFile - the keystore file path
    • getCertificateKeystoreFile

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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