Hi Carlos and Hermann
I was working on a connection SSL/TLS in one way authentication or with self-signed certificate and I recommend you do the next three task.
Task 1. Connection validation: check the certificate types if you have certificates in .pem format probably you use openssl to generate it, to check the connection with your files from a remote client, execute on terminal the next command.
$openssl s_client -connect host.ibmcloud.com:port -key our_private_key.pem -showcerts -cert our_server-signed_cert.pem
if output is success connection now you can generate your keystore.
Task 2. how to generate the keystore.jks?
Create a keystore on pkcs12 format with the key.pem and cert.pem
$openssl pkcs12 -export -inkey key.pem -in cert.pem -out client.packet
the comand require a password: #PASSWORD#
create a keystore with format jks based on the keystore with format pkcs12
$keytool -importkeystore -deststorepass #PASSWORD# -destkeypass #PASSWORD# -destkeystore keystore.jks -srckeystore client.packet -srcstoretype PKCS12 -srcstorepass #PASSWORD# -alias 1
add ca2-cert.pem to the keystore.jks
$keytool -importcert -alias ca -trustcacerts -file /root/ca2-cert.pem -keystore keystore.jks
now the keystore.jks has the ca2-cert.pem and the keystore.packet(that contains the key.pem and cert.pem)
Task 3. The next task is configuration of your server.xml on liberty profile.
configure the keystore parameters on the properties.db2.jcc is very important put the parameter sslConnection="true"
For example:
<dataSource beginTranForResultSetScrollingAPIs="false"
beginTranForVendorAPIs="false" connectionSharing="MatchCurrentState"
isolationLevel="TRANSACTION_READ_COMMITTED"
jndiName="jdbc/#######" queryTimeout="10"
statementCacheSize="10" syncQueryTimeoutWithTransactionTimeout="false"
transactional="false">
<jdbcDriver
javax.sql.ConnectionPoolDataSource="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
libraryRef="DB2Lib" />
<properties.db2.jcc currentLockTimeout="10"
currentSchema="####" cursorSensitivity="0" databaseName="####"
deferPrepares="true" driverType="4" loginTimeout="0"
password="####" portNumber="###" resultSetHoldability="1"
retrieveMessagesFromServerOnGetMessage="true"
serverName="####.ibmcloud.com" traceLevel="-1"
user="####" sslConnection="true" />
<connectionManager agedTimeout="7200"
connectionTimeout="180" maxIdleTime="1800" maxPoolSize="10"
minPoolSize="1" purgePolicy="EntirePool" reapTime="180" />
dataSource>
and configure server.xml keystore parameters. For example:
<sslDefault sslRef="defaultSSLSettings" />
<ssl clientAuthenticationSupported="false" id="defaultSSLSettings"
keyStoreRef="defaultKeyStore" pollingRate="5s" updateTrigger="polled"
trustStoreRef="defaultKeyStore" />
<keyStore id="defaultKeyStore" password="#####" fileBased="true"
updateTrigger="mbean" readOnly="true" type="JKS" location="/location/keystore.jks">
keyStore>
after that create in your server root folder a file named “jvm.options” with next jdk parameters.
-Djavax.net.ssl.keyStore = /location/keystore.jks
-Djavax.net.ssl.keyStorePassword = #######
-Djavax.net.ssl.trustStore = /location/keystore.jks
-Djavax.net.ssl.trustStoreType=jks
-Djavax.net.ssl.trustStorePassword = #######
this work for me and I wait help you.
System Information
OS:RHEL 7.4
IDE: EclipseOxygen
AS: Liberty Profile
JDBC: IBM Data Server Driver for JDBC and SQLJ 4.24.92
References
http://fm4dd.com/database/howto-encrypt-IBMdb2-jdbc.htm
https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/rwlp_ssl.html