Generating and using self-signed certificates
About this task
Procedure
Example
- Create a key
database:
gsk8capicmd_64 -keydb -create -db "mydbclient.kdb" -pw "password" -stash - Add the signer certificate into the client key
database:
gsk8capicmd_64 -cert -add -db "mydbclient.kdb" -pw "password" -label "dbselfsigned" -file rootCA.pem -format ascii - Use the ssl_clnt_keydb and ssl_clnt_stash configuration parameters to specify the
client key-database and the stash
file:
db2 update dbm cfg using SSL_CLNT_KEYDB /mnt/clientdir/clienthome/db2inst1/mydbclient.kdb SSL_CLNT_STASH /mnt/clientdir/clienthome/db2inst1/mydbclient.sth - Catalog the node and database so that client applications can establish TLS connections to
them:
db_catalog --add ma-bhpwr10-7.swg.usma.ibm.com --ssl --alias mydb - Log out, log in and connect to the
database:
db2 connect to mydb user <db_username> using <password>
Known issues
- BLUDR doesn’t work.
WORKAROUND:
To refresh the Db2 ssl certificate for BLUDR:- On the source system, in the Db2 container, as
su-dsadm:- Ensure that
BLUDR_SHARED_DIRis set:- On IAS or Db2 Warehouse on Cloud:
BLUDR_SHARED_DIR=/head/bludr - On Db2 Warehouse:
BLUDR_SHARED_DIR=/mnt/blumeta0/bludr
- On IAS or Db2 Warehouse on Cloud:
- Import local Db2 ssl certificate to the BLUDR truststore:
-
/opt/ibm/java/jre/bin/keytool -delete -keystore ${BLUDR_SHARED_DIR}/certificates/cacerts -storepass "$(base64 -d ${BLUDR_SHARED_DIR}/certificates/truststore_pwd)" -alias db2_ssl -noprompt -
/opt/ibm/java/jre/bin/keytool -import -trustcacerts -keystore ${BLUDR_SHARED_DIR}/certificates/cacerts -storepass "$(base64 -d ${BLUDR_SHARED_DIR}/certificates/truststore_pwd)" -alias db2_ssl -noprompt -import -file /mnt/blumeta0/db2/ssl_keystore/rootCA.pem
-
- Import the target Db2 ssl certificate to the BLUDR truststore.
The certificate is available at /mnt/blumeta0/db2/ssl_keystore/rootCA.pem inside the database container. You can extract the self-signed root CA certificate to your system. For more information, see the Procedure section.
-
/opt/ibm/java/jre/bin/keytool -delete -keystore ${BLUDR_SHARED_DIR}/certificates/cacerts -storepass "$(base64 -d ${BLUDR_SHARED_DIR}/certificates/truststore_pwd)" -alias db2_ssl_<target_hostname> -noprompt -
/opt/ibm/java/jre/bin/keytool -import -trustcacerts -keystore ${BLUDR_SHARED_DIR}/certificates/cacerts -storepass "$(base64 -d ${BLUDR_SHARED_DIR}/certificates/truststore_pwd)" -alias db2_ssl_<target_hostname> -noprompt -import -file ${BLUDR_SHARED_DIR}/certificates/<target_hostname>_rootCA.pem
-
- As the
rootordb2inst1user, import the remote target Db2 root certificate to the local Db2 ssl keystore for Db2CLP:opt/ibm/db2/V11.5.0.0/gskit/bin/gsk8capicmd_64 -cert -add -db /mnt/blumeta0/db2/ssl_keystore/bludb_ssl.kdb -stashed -label db2_ssl_rootCA_<target_hostname> -file ${BLUDR_SHARED_DIR}/certificates/<target_hostname>_rootCA.pem -format ascii -trust enable -fips - Verify the Db2 certificate aliases in the BLUDR truststore
:
keytool -v -list -keystore ${BLUDR_SHARED_DIR}/certificates/cacerts -storepass "$(base64 -d ${BLUDR_SHARED_DIR}/certificates/truststore_pwd)" | grep Alias -A10 | grep db2 -A10 - Restart the bludr server and web console.
Run the restart commands as the
dsadmuser:- The bludr server:
/opt/ibm/bludr/scripts/bin/bludr-restart.sh - The web console:
- On Db2 Warehouse:
/opt/ibm/dsserver/bin/restart.sh - On IAS:
- Restart the API server:
systemctl restart apiserver - From the IAS console, on the
platform
ap apps disable webconsole ap apps enable webconsole
- Restart the API server:
- On Db2 Warehouse:
- The bludr server:
- Ensure that
- On the target system, do the same steps as for the source system. Import the source Db2 ssl certificate and local Db2 ssl certificate to the BLUDR truststore, and import the remote source Db2 root certificate for Db2CLP.
- On the source system, in the Db2 container, as
- Lift to cloud doesn’t work.
WORKAROUND:
- Restart the web console container:
ap apps restart WEBCONSOLE - Type y when prompted to restart the web
console:
WebConsole will be restarted. Are you sure you want to proceed? [y/N]: y Restart request sent successfully
- Restart the web console container:
- The db_migrate_iias command doesn’t work with
ssl.WORKAROUND:
Run the commands from the source or target machine from which you want to invoke db_migrate_iias.- As the
db2inst1user inside thedb2whcontainer, verify thatSSL_CLNT_KEYDBandSSL_CLNT_STASHare set. If they are not set, set them:
Example:db2 update dbm cfg using SSL_CLNT_KEYDB /mnt/blumeta0/db2/ssl_keystore/bludb_ssl.kdb SSL_CLNT_STASH /mnt/blumeta0/db2/ssl_keystore/bludb_ssl.sth[db2inst1@ma-bhpwr5-8 - Db2wh /]$ db2 update dbm cfg using SSL_CLNT_KEYDB /mnt/blumeta0/db2/ssl_keystore/bludb_ssl.kdb SSL_CLNT_STASH /mnt/blumeta0/db2/ssl_keystore/bludb_ssl.sth DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully. - Extract the self-signed root CA certificate from the other system.
For more information, see the Procedure section.
- Add the certificate to the
db2whdefault truststore:[db2inst1@ma-bhpwr5-8 - Db2wh ~]$ /opt/ibm/db2/V11.5.0.0/gskit/bin/gsk8capicmd_64 -cert -add -db /mnt/blumeta0/db2/ssl_keystore/bludb_ssl.kdb -stashed -label ss_bluhel21 -file <fully_qualified_path_to_the_CA_cert_copied> -format ascii -trust enable -fips
- As the
- After a head node failover, the web console can’t access the database.
WORKAROUND:
You must run the installation script again in theweb_consolecontainer on the new head node after head node failover:docker cp install_self_signed_cert.sh web_console:/scratch docker exec -it web_console bash /scratch/install_self_signed_cert.sh -p IIASweb - The dbload and dbsql commands don’t work with
ssl.WORKAROUND:
Set up the client to trust the certificate as described in Step 3 and Step 4. There's no need to catalog the database. - While running the db_restore command from
web_console, a Database restore failed on the web console. error appears. The restore actually succeeds in backend.WORKAROUND:
To validate the progress of the restore operation, as
bluadmin, run the db2 list utilities show detail command to establish if a restore is running.If a restore operation is in progress, the example output for each MLN is:Restore percentage output: ID = 1 Type = RESTORE Database Name = BLUDB Member Number = 1 Description = db Start Time = 09/02/2020 09:57:33.923808 State = Executing Invocation Type = User Progress Monitoring: Completed Work = 922976256 bytes Start Time = 09/02/2020 09:57:33.923813ID = 1 Type = RESTORE Database Name = BLUDB Member Number = 2 Description = db Start Time = 09/02/2020 09:57:33.904257 State = Executing Invocation Type = User Progress Monitoring: Completed Work = 922976256 bytes Start Time = 09/02/2020 09:57:33.904264You can find a log file associated with this restore operation in the /opt/ibm/appliance/storage/scratch/bluadmin_BNR/logs directory directory. Review the logs in the most recent restore log and tracelog for progress details.