5

我尝试使用Websphere Liberty®上的选项来设置JDBC driversecurityMechanism属性,并参考以下 IBM® Knowledge Center,但在我启动 Websphere Liberty(2015 年 7 月的测试版)时收到一条警告消息。TLS_CLIENT_CERTIFICATE_SECURITYCWWKG0032W

您能告诉我如何使用Websphere Liberty 上securityMechanism的选项设置 JDBC 驱动程序的属性吗?TLS_CLIENT_CERTIFICATE_SECURITY

IBM Data Server Driver for JDBC and SQLJ 支持证书认证

IBM® Data Server Driver for JDBC and SQLJ 支持客户端支持证书认证以连接到 DB2® for z/OS® Version 10 或更高版本的数据服务器。

当 Websphere Liberty 服务器启动时的console.log

CWWKG0032W: Unexpected value specified for property
            [securityMechanism], value = [18]. >Expected value(s) are:
            [3][4][7][9][11][12][13][15][16].

securityMechanism="18"TLS_CLIENT_CERTIFICATE_SECURITY,我通过以下方式确认了该值:

\>javac -classpath .;db2jcc4.jar; JDBCCheck
\>java -classpath .;db2jcc4.jar; JDBCCheck
  TLS_CLIENT_CERTIFICATE_SECURITY: 18

JDBCCheck类:

class JDBCCheck{
  public static void main(String args[]){
    com.ibm.db2.jcc.DB2SimpleDataSource dataSource =
                                   new com.ibm.db2.jcc.DB2SimpleDataSource();
    System.out.println( "TLS_CLIENT_CERTIFICATE_SECURITY: "
                        + dataSource.TLS_CLIENT_CERTIFICATE_SECURITY);
  }
}

服务器.xml

<library id="db2-library">
  <fileset dir="lib" id="db2-fileset" includes="db2jcc4.jar db2jcc_license_cu.jar"/>
</library>

<dataSource id="db2" jndiName="jdbc/sampledb">
  <jdbcDriver libraryRef="db2-library"/>
  <properties.db2.jcc databaseName="SAMPLEDB" password="password" portNumber="10443"
              serverName="XX.XX.XX.XX" user="db2inst1" sslConnection="true"
              sslTrustStoreLocation="ssld/defaultTrustStore"
              sslTrustStorePassword="trustpassword" securityMechanism="18"/>
</dataSource>

更新01:

  • db2jcc4.jar级别/版本是DB2 10.5FP1.
  • CWWKG0032W当我使用通用 JDBC 驱动程序属性properties而不是DB2® JCC 属性时, Websphere Liberty 启动时没有警告properties.db2.jcc
4

3 回答 3

2

基于 IBM® Knowledge Center 中的此主题: Java EE Full Platform 7.0部分:transaction > dataSource > properties.db2.jcc

目前,WebSphere Liberty 仅支持 securityMechanism 的以下值:

  • value="3" name="CLEAR_TEXT_PASSWORD_SECURITY"
  • 值="4" 名称="USER_ONLY_SECURITY"
  • value="7" name="ENCRYPTED_PASSWORD_SECURITY"
  • value="9" name="ENCRYPTED_USER_AND_PASSWORD_SECURITY"
  • 值="11" 名称="KERBEROS_SECURITY"
  • value="12" name="ENCRYPTED_USER_AND_DATA_SECURITY"
  • value="13" name="ENCRYPTED_USER_PASSWORD_AND_DATA_SECURITY"
  • value="15" name="PLUGIN_SECURITY"
  • value="16" name="ENCRYPTED_USER_ONLY_SECURITY"

如果您希望将 TLS_CLIENT_CERTIFICATE_SECURITY 添加为 Liberty 中的安全机制,我建议您打开一个 RFE,以便 Liberty 开发人员了解支持此功能的需求。

更新:
要解决这个问题,您仍然可以指定 securityMechanism="18",但只需在通用 <properties> 元素中执行此操作,而不是在 db2 特定 <properties.db2.jcc> 元素中执行此操作(看起来您已经想到已经出来了)。

于 2015-06-29T17:51:49.040 回答
1

另一种设置方式TLS_CLIENT_CERTIFICATE_SECURITY是:

com.ibm.db2.jcc.DB2SimpleDataSource dataSource = new 
                                    com.ibm.db2.jcc.DB2SimpleDataSource();
dataSource.setSecurityMechanism 
           (com.ibm.db2.jcc.DB2BaseDataSource.TLS_CLIENT_CERTIFICATE_SECURITY);

查看此 IBM® 知识中心以获取更多信息:

IBM Data Server Driver for JDBC and SQLJ 支持证书认证

这应该适用于 Websphere Full Profile 和 Websphere Liberty Profile。

于 2015-07-14T20:37:01.210 回答
1

这是使用用户标识和加密密码设置安全机制以建立 DB2 连接的代码。传递用户名、密码和 url 字符串。

Properties properties = new Properties(); // Create a Properties object
    properties.put("user", user);          // Set user ID for the connection
    properties.put("password", password);      // Set password for the connection
    properties.put("securityMechanism", 
      new String("" + 
      DB2BaseDataSource.ENCRYPTED_USER_AND_PASSWORD_SECURITY +
      ""));
                                              // Set security mechanism to 
                                              // user ID and encrypted password
    properties.put("encryptionAlgorithm", "2");

    Connection connection = DriverManager.getConnection("jdbc:db2://" + url, properties);
于 2018-12-07T09:43:08.790 回答