SSL/TLS to a Db2 for LUW source¶
TLS encrypts the agent's connection to the source and, with the log reader stored procedure, the log records it reads. The Replicator Service's connection is encrypted separately, in the SQDR source.
Set up TLS in Db2¶
The database administrator uses IBM GSKit (Global Security Kit, installed with Db2) to create a keystore and a server certificate, then sets Db2 to use them. A self-signed certificate is enough for Stelo Capture and StarSQL on Windows; a certificate signed by a certificate authority (CA), public or your own, is more secure and needed for other clients.
- With
gsk8capicmd_64: create a keystore with a stash file, create the certificate (self-signed, or from a certificate request your CA signs), and export the certificate of the CA (or the self-signed certificate) for the clients, in ASCII (.arm) format. -
Set the database manager configuration, enable TLS, and restart Db2 (here with the TLS port 50448):
db2 update dbm cfg using SSL_SVR_KEYDB C:\SSL\DB2\mydbserver.kdb db2 update dbm cfg using SSL_SVR_STASH C:\SSL\DB2\mydbserver.sth db2 update dbm cfg using SSL_SVR_LABEL SelfSigned db2 update dbm cfg using SSL_SVCENAME 50448 db2 update dbm cfg using SSL_VERSIONS TLSv12 db2set DB2COMM=SSL,TCPIP db2stop db2startSSL_VERSIONS TLSv12is optional: it enforces TLS 1.2.
Example scripts that do all of it, for a self-signed certificate or a CA-signed one: db2luw_selfsigned.bat, db2luw_ssl.bat (Windows), and db2luw_selfsigned.sh, db2luw_ssl.sh (Linux and UNIX).
Connect the Capture Agent with TLS¶
- Add the exported certificate on the SQDR Control Center's Certificates tab (see The Certificates tab).
- When you add the agent, enter the TLS port as Port Number and select Use SSL/TLS.
To change an existing agent, on its Configuration tab change sourceDbPort to
the TLS port, and in sourceDbUrl change the port and add sslConnection=true; at the end, for example
jdbc:db2://srchost:50448/SRCDB:driverType=4;deferPrepares=false;sslConnection=true;. Add useSSL with the value
true too, and save.
Connect SQDR with TLS¶
- StarSQL: connect to the TLS port with the TLS network library, for example
HostName=srchost;Netlib=SQSSL.DLL;Port=50448;Server=SRCDB;PkgColID=SQDR. -
IBM Db2 ODBC driver: on the Stelo VM, create a GSKit keystore and add the exported certificate to it, for example:
set GSK=C:\Program Files\IBM\gsk8\bin\gsk8capicmd_64 mkdir C:\SSL cd C:\SSL "%GSK%" -keydb -create -db keystore.kdb -pw "<password>" -stash "%GSK%" -cert -add -db keystore.kdb -pw "<password>" -label SelfSigned -file mydbserver.arm -format ascii -fipsThen use a connection string such as
Hostname=srchost;Port=50448;Database=SRCDB;Protocol=TCPIP;Authentication=SERVER;SECURITY=SSL;Ssl_client_keystoredb=C:\SSL\keystore.kdb;Ssl_client_keystash=C:\SSL\keystore.sth.
If the connection fails, see "GSKit Error 408" or "GSKit Error 414".