SSL 配置属性
SSL 配置包含用来控制 Liberty 上服务器 SSL 传输层的行为的属性。此主题复述适用于 SSL 配置的所有设置。
SSL 功能部件
要在服务器上启用 SSL,必须在 server.xml 文件中包括 SSL 功能部件:
<featureManager>
<feature>ssl-1.0</feature>
</featureManager>
SSL 缺省值
可以配置多项 SSL 配置。如果配置了多项 SSL 配置,那么必须在 server.xml 文件中使用 sslDefault 服务配置来指定缺省 SSL 配置。
属性 | 描述 | 缺省值 |
---|---|---|
sslRef | sslRef 属性指定要用作缺省值的 SSL 配置的名称。 | 缺省 SSL 配置名称是 defaultSSLConfig。 |
在 server.xml 文件中,条目如下所示:
<sslDefault sslRef="mySSLSettings" />
SSL 配置
使用 SSL 配置属性来定制 SSL 环境以适合需求。可以在 server.xml 文件中的 ssl 服务配置元素上设置这些属性。
属性 | 描述 | 缺省值 |
---|---|---|
id | id 属性对 SSL 配置对象指定唯一名称。 | 没有缺省值;必须指定唯一名称。 |
keyStoreRef | keyStoreRef 属性指定用来定义 SSL 配置密钥库的密钥库服务对象。密钥库保存建立 SSL 连接所需的密钥。 | 没有缺省值;必须指定密钥库引用。 |
trustStoreRef | trustStoreRef 属性指定用来定义 SSL 配置信任库的密钥库服务对象。信任库保存对验证进行签名所需的证书。 | trustStoreRef 是可选属性。如果缺少引用,那么会使用 keyStoreRef 所指定的密钥库。 |
clientAuthentication | clientAuthentication 属性确定是否需要 SSL 客户机认证。 | 缺省值为 false。 |
clientAuthenticationSupported | clientAuthenticationSupported 属性确定是否支持 SSL 客户机认证。客户机不必提供客户机证书。如果 clientAuthentication 属性设置为 true,那么会覆盖 clientAuthenticationSupported 属性的值。 | 缺省值为 false。 |
sslProtocol | sslProtocol 属性定义 SSL 握手协议。协议可能依赖于 SDK,因此如果您修改协议,请确保据以运行的 SDK 支持该值。 | 缺省值为 SSL_TLSv2(对于 IBM® JRE)和 SSL(对于 Oracle JRE)。 |
securityLevel | securityLevel 属性确定 SSL 握手要使用的密码套件组。该属性具有下列其中一个值:
|
缺省值为 HIGH。 |
enabledCiphers | enabledCiphers 属性用于指定唯一的密码套件列表。使用空格来分隔列表中的每个密码套件。如果设置了 enabledCiphers 属性,那么会忽略 securityLevel 属性。 | 没有缺省值。 |
serverKeyAlias | serverKeyAlias 属性指定密钥库中要用作 SSL 配置密钥的密钥。只有在密钥库中具有多个密钥条目时,才需要此属性。如果密钥库具有多个密钥条目,且此属性未指定密钥,那么 JSSE 会选取密钥。 | 没有缺省值。 |
clientKeyAlias | clientKeyAlias 属性指定密钥库中要用作 SSL 配置密钥的密钥(在启用 clientAuthentication 的情况下)。只有在密钥库中包含多个密钥条目时,才需要此属性。 | 没有缺省值。 |
注:
- SSL 握手使用密钥管理器来确定要使用的证书别名。未在 server.xml 文件中配置密钥管理器。它是从 SDK 的安全属性 ssl.KeyManagerFactory.algorithm 检索到的。
- SSL 握手使用信任管理器来作出信任决策。未在 server.xml 文件中配置信任管理器。它是从 SDK 的安全属性 ssl.TrustManagerFactory.algorithm 检索到的。
下面举例说明了如何在 server.xml 文件中配置 ssl 元素:
<!-- Simple ssl configuration service object. This assumes there is a keystore object named -->
<!-- defaultKeyStore and a truststore object named defaultTrustStore in the server.xml file. -->
<ssl id="myDefaultSSLConfig"
keyStoreRef="defaultKeyStore"
trustStoreRef="defaultTrustStore" />
<!-- A ssl configuration service object that enabled clientAuthentication -->
<!-- and specifies the TLS protocol be used. -->
<ssl id="myDefaultSSLConfig"
keyStoreRef="defaultKeyStore"
trustStoreRef="defaultTrustStore"
clientAuthentication="true"
sslProtocol="TLS" />
<!-- An SSL configuration service object that names the serverKeyAlias -->
<!-- to be used by the handshake. This assumes there is a certificate -->
<!-- called "default" in the keystore defined by keyStoreRef. -->
<ssl id="myDefaultSSLConfig"
keyStoreRef="defaultKeyStore"
serverKeyAlias="default" />
密钥库配置
keystore 配置由装入密钥库时所需的属性组成。可以在 server.xml 文件中的密钥库服务配置上设置这些属性。
属性 | 描述 | 缺省值 |
---|---|---|
id | id 属性定义密钥库对象的唯一标识。 | 没有缺省值,必须指定唯一名称。 |
location | location 属性指定密钥库文件名。值可以包含文件的绝对路径。如果未提供绝对路径,那么代码会在 ${server.config.dir}/resources/security 目录中查找该文件。 | 在 SSL 最低配置中,会假定该文件的位置为 ${server.config.dir}/resources/security/key.jks。 |
type | type 属性指定密钥库的类型。检查据以运行的 SDK 支持您所指定的密钥库类型。 | 缺省值为 jks。 |
password | password 属性指定用于装入密钥库文件的密码。可以采用明文或编码格式存储该密码。有关如何对密码进行编码的信息,请参阅 securityUtility encode 选项。 | 必须提供。 |
provider | provider 属性指定要用于装入密钥库的提供程序。某些密钥库类型需要提供程序,而不是 SDK 缺省值。 | 缺省情况下,未指定任何提供程序。 |
fileBased | fileBased 属性指定密钥库是否基于文件。 | 缺省值为 true。 |
pollingRate | 服务器检查密钥库文件更新的频率。 | 500ms。 |
updateTrigger | 该方法用于触发服务器以重新装入密钥库文件。指定 polled 以允许服务器检查密钥库文件的更改,指定 mbean 以允许服务器等待 mbean 重新装入密钥库文件,或指定 disabled 以禁用文件监视。 | disabled。 |
如果 updateTrigger 属性设置为 polled 或 mbean,那么服务器可重新装入密钥库文件。如果启用了 polled,那么服务器会根据 pollingRate 属性中设置的速率监视密钥库文件的更改。如果 updateTrigger 属性设置为 mbean,那么服务器从 WebSphere:service=com.ibm.ws.kernel.filemonitor.FileNotificationMBean MBean 接收到通知时将重新装入密钥库文件。缺省情况下,文件监视被禁用。
下面举例说明了如何在 server.xml 文件中配置 keystore 元素:
<!-- A keystore object called defaultKeyStore provides a location, -->
<!-- type, and password. The MyKeyStoreFile.jks file is assumed -->
<!-- to be located in ${server.config.dir}/resources/security -->
<!-- This keystore is configured to be monitored every 5 seconds -->
<!-- for updates -->
<keyStore id="defaultKeyStore"
location="MyKeyStoreFile.jks"
type="JKS" password="myPassword"
pollingRate="5s"
updateTrigger="polled" />
<!-- A keystore object called defaultKeyStore provides a location, -->
<!-- type, and password. The MyKeyStoreFile.jks file is assumed -->
<!-- to be located in ${server.config.dir}/resources/security -->
<!-- This keystore is configured to be reloaded when the server -->
<!-- recieves an mbean notification to do so -->
<keyStore id="defaultKeyStore"
location="MyKeyStoreFile.jks"
type="JKS" password="myPassword"
updateTrigger="mbean" />
完整 SSL 配置示例
下面举例说明了 server.xml 文件中的完整 SSL 配置。此示例具有下列 SSL 配置:
- defaultSSLSettings
- mySSLSettings
<featureManager>
<feature>ssl-1.0</feature>
</featureManager>
<!-- default SSL configuration is defaultSSLSettings ->
<sslDefault sslRef="defaultSSLSettings" />
<ssl id="defaultSSLSettings"
keyStoreRef="defaultKeyStore"
trustStoreRef="defaultTrustStore"
clientAuthenticationSupported="true" />
<keyStore id="defaultKeyStore"
location="key.jks"
type="JKS" password="defaultPWD" />
<keyStore id="defaultTrustStore"
location="trust.jks"
type="JKS" password="defaultPWD" />
<ssl id="mySSLSettings"
keyStoreRef="myKeyStore"
trustStoreRef="myTrustStore"
clientAuthentication="true" />
<keyStore id="LDAPKeyStore"
location="${server.config.dir}/myKey.p12"
type="PKCS12"
password="{xor}CDo9Hgw=" /> <keyStore id="LDAPTrustStore"
location="${server.config.dir}/myTrust.p12"
type="PKCS12"
password="{xor}CDo9Hgw=" />