Search This Blog

Showing posts with label cognos SSL. Show all posts
Showing posts with label cognos SSL. Show all posts

2023-10-20

SSL Setup - Java https, smtp, MS SQL Server

Technology: Java using SSL Certificate, or TLS1.2 - 1.3 encryption

Product: web server (https), SMTP email, force encryption MS SQL Server

There are several steps involve in setup SSL for various servers besides following standard

1. Create new SSL certificate for the virtual hostname used by the applications

2. Import the SSL certificate to the application servers

2.1. For Java, you need to import into Java keystore. For OpenJDK or Oracle Java (JRE), it is located in [java_jre_home]\lib\security, or [java_jdk_home\jre\lib\security.

2.2. For Linux or Windows binary programs, you need to import into OS. For RHEL, the SSL certificate file will be /etc/ssl/certs

3. Configures the application server to enable SSL, and indirectly specified the SSL certificate to use

4. Configures the application client to enable SSL, and optionally

4.1. Java - optionally specifies SSL keystore if not using default

Now, let's pick an application that leverages multiple technologies, and gives real picture what needs to be configured to enable SSL

Cognos Analytics report server

This reporting server has following functionality (typical, but could be more) that will has SSL encryption:

1. Web server - it is severing the report in html, so it is a web server

2. Web client - it is able to forward its traffic to a customer facing web server (IIS, Apache httpd, IBM httpd), so for this communication, it is a web client

3. SMTP email client - its interactive report and scheduled report can be sent out as email attachment (pdf, html)

4. DB client - it needs a "Content Store" DB to stores user credential and report template. It can has additional audit DB to store additional application data for audit functionality.  Any DB that it is querying to display the reports are all act as a DB client

5. Authentication client - OOTB LDAP (Windows only) server, custom LDAP, Okta, IBM OpenConnect, etc authentication that it supports, it is acting as client

Therefore, for above 5 typical server & client functionality, SSL can be enabled and encrypts the traffic between remote servers and clients.

For all the above functionality, you need to understand that the product is a pure Java J2EE application.  Therefore, all the SSL configuration will follow Java (standard) and IBM documentation (application specific).

Several and multiple SSL certificates involve in this encryption setup:

1. Java keystore located in [cognos_home]\configuration\certs\CAMKeystore (default password NoPassWordSet)

1.1. CAMKeystore keeps the SSL cert for web/https access for Cognos Analytics server. If there are multiple virtual hostname (such as internal access, intranet access, internet access), then there are multiple SSL certs (unless the SSL cert contains multiple virtual hostname)
1.2. CAMKeystore keeps the SSL cert for Cognos Analytics server's databases access, e.g. Content DB, audit DB, data store DB. Example is MS SQL Server force encryption. Each remote DB server uses different SSL cert, and CA root
1.3. CAMKeystore keeps the SSL cert for SMTP server, which used for email of report, or email notification functionality. Example is smtp protocol with STARTTLS that enforce SSL, or smtps protocol. Typically only 1 SMTP server, so only 1 SSL cert
1.4. CAMKeystore keeps the SSL cert for client side https with remote customer users facing web server
1.5. CAMKeystore keeps the SSL cert for remote authentication server, e.g. LDAP , ActiveDirectory, and SSO. Each authentication server has its own SSL cert

Procedure:

1. Determine the root certificate for all 5 components above.  Each server will have its own SSL cert, and might not use the same CA root certificate

2. Verify in [cognos_home]\configuration\certs\CAMKeystore that the CA root certificate is already there, and will be recognize

2.1. Follows Cognos Analytics doc: DLS_SSL_CertImportTool.bat (Windows), or sh (Linux) - https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=server-enabling-secure-tls-connection-your-email

3. Even if it is in CAMKeystore, verify that it is not expired

4. If not there, or expired, then export the CA root cert from remote server

5. Import into CAMKeystore, which is the IBM Java keystore

6. For DB used in data store, import the SSL cert into [cognos_home]\ibm-jre\jre\lib\security\cacerts

6. Follows various IBM Cognos Analytics document to enable SSL encryption

6.1. For Cognos Analytics 12.0.0 SMTP - https://www.ibm.com/docs/en/cognos-analytics/12.0.0?topic=server-enabling-secure-tls-connection-your-email

6.2. For Cognos Analytics 11.2.0 Content DB, audit DB, logging DB as database client - https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=communications-enabling-ssl-db2-informix-databases

6.3. For data store as DB client - https://www.ibm.com/docs/en/cognos-analytics/11.2.0?topic=communications-enabling-ssl-db2-informix-databases

Tools

There are various DOS utilities that can troubleshoot SSL communication, but none for Java.  Some sample Java programs are available, but you have to compile, as well as familiar with SSL logging parameters that you have to manually specify.

Tools for

1. Windows: openssl

2. UNIX, Linux - openssl, curl

3. Java SMTP - Oracle javamail-samples.zip that based on Oracle javax.mail.jar library that you need to download. It contains sample SMTP with STARTTLS sample code that you need to modify the Java program to specify SMTP port (default port 25)

4. Java MS SQL Server client - Microsoft provided sample https://learn.microsoft.com/en-us/sql/connect/jdbc/connection-url-sample?view=sql-server-ver16

Tool - opemnssl for SMTP

For SMTP that uses STARTTLS to enable encryption, uses following command to troubleshoot SSL issue

openssl s_client -starttls smtp -crlf -connect [remote email server hostname]:[smtp port]

This relies on OS SSL certificate store, so not applicable for Java SMTP troubleshooting

Tool - opemnssl for SMTPS

Same as above, but uses SMTPS SSL encryption, not SMTP + STARTTLS

openssl s_client  smtps -crlf -connect [remote email server hostname]:[smtp port]

Tool - curl for SMTP

curl is preinstalled in Linux.  It can login to SMTP email server, and send out email.  Therefore, it is useful to ensure the remote SMTP server is properly configured to allow your application server to send out email. This uses SMTP + STARTTLS protocol

curl -v  smtp://email-smtp.us-east-1.amazonaws.com:587  --user "login-user-name:password-to-be-filled" --mail-from "[username that allow to be used to send out" --mail-rcpt "email addr to receive the email"  -T emailcontent.txt --ssl

Tool - curl for SMTPS

Same as above, but uses SMTPS instead of SMTP + STARTTLS

curl -v  smtps://email-smtp.us-east-1.amazonaws.com:587  --user "login-user-name:password-to-be-filled" --mail-from "[username that allow to be used to send out" --mail-rcpt "email addr to receive the email"  -T emailcontent.txt

Tool - Test-NetConnection

PowerShell Test-NetConnection can be used to verify the application server machine can reach remote SMTP/DB/LDAP/Okta/SSO/web server.  This will give you a quick indication that the firewall, router, DNS, AWS Security Group, etc are configured to allow them to talk before you perform application side of testing, such as openssl, or curl above

test-netconnection [remote server hostname] -port [remote server port]

Example for MS SQL Server: test-netconnection [remote MS SQL Server virtual hostname] -port 1433

Example for web server: test-netconnection [remote web server virtual hostname] -port 443

Example for Oracle DB: test-netconnection [remote Oracle virtual hostname] -port 1521

Tool - Java

Enable following SSL debug parameter when running sample MS SQL Server, Oracle sample JavaMail program, etc

Example for using Oracle JavaMail sample called smtpsend.java: java  -cp .;..\javax.mail.jar;..\javax.activation-api-1.2.0.jar  -Djavax.net.debug=ssl:handshake smtpsend

2019-08-28

Cognos Analytics: Advance SSL Certificate Import

Product: IBM Cognos Analytics
Version: 10.2.x, 11.0.x, 11.1.x
Main Cognos Online Doc: Cognos Analytics 11.0.x Installing & Configuring > Configuration options

This post is related to Cognos Analytics SSL configuration that listed below:

11.0.x: Import the CA certificates into IBM Cognos components (11.0.x)
11.1.x: Import the CA certificates into IBM Cognos components (11.1.x)

The procedure only work for following SSL certificate, which IBM didn't document in Cognos documentation for 10 years or longer:
1. self-sign SSL certificate - no hierachy
2. self-sign SSL certificate - only has 1 CA certificate to import
3. paid SSL certificate - CA certificate is the root certificate
4. paid SSL certificate - Just 1 root CA cert, and 1 intermediate cert, where root CA cert is already in keystore

In contrast, this step doesn't consider following real life scenarios:

  1. Customer buy a public SSL certificate instead of using self-sign certificate
  2. There is a chain of SSL CA certificate whenever you buy a public SSL certificate
  3. A corporate self-sign certificate could also centrally managed with CA hierarchy/chain
  4. Root CA certificate is not in the Cognos Analytics' default Java trust store
  5. Even if root CA certificate is in the Cognos Analytics' default Java trust store, if there is more than 1 intermediate CA certificate in the chain
So following scenarios could result in Step 4 of the ThirdPartyCertificateTool.sh/.bat failed with following error:


D:\cognos\analytics\bin> ThirdPartyCertificateTool.bat -i -e -r encryptCertificate.cer -p NoPassWordSet -t ca.cer
Looking in: \bin...
Looking in: \jre\bin...
Executing:
\jre\bin\java.exe  com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool -i -e -r encryptCertificate.cer -p NoPassWordSet -t ca.cer
log4j:WARN No appenders could be found for logger (Trace.CAM.JCAM).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

CAM-CRP-1238 Unable to store the third party crypto certificate. Unable to build the entire certificate chain. Ensure that the CA certificate file contains the entire CA certificate chain.
Reason: java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter.storeThirdPartyCamCryptoCert(KeyStoreWriter.java:1256)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.installCamCryptoKeyCert(ThirdPartyCertificateTool.java:450)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.main(ThirdPartyCertificateTool.java:511)
Caused by: CAM-CRP-1240 Unable to build the entire certificate chain. Ensure that the CA certificate file contains the entire CA certificate chain. Reason: java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1422)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter.storeThirdPartyCamCryptoCert(KeyStoreWriter.java:1250)
        ... 2 more
Caused by: java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at org.bouncycastle145.jce.provider.PKIXCertPathBuilderSpi.engineBuild(PKIXCertPathBuilderSpi.java:112)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1418)
        ... 3 more
CAM-CRP-1240 Unable to build the entire certificate chain. Ensure that the CA certificate file contains the entire CA certificate chain. Reason: java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1422)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter.storeThirdPartyCamCryptoCert(KeyStoreWriter.java:1250)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.installCamCryptoKeyCert(ThirdPartyCertificateTool.java:450)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.main(ThirdPartyCertificateTool.java:511)
Caused by: java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at org.bouncycastle145.jce.provider.PKIXCertPathBuilderSpi.engineBuild(PKIXCertPathBuilderSpi.java:112)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1418)
        ... 3 more
java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at org.bouncycastle145.jce.provider.PKIXCertPathBuilderSpi.engineBuild(PKIXCertPathBuilderSpi.java:112)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1418)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter.storeThirdPartyCamCryptoCert(KeyStoreWriter.java:1250)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.installCamCryptoKeyCert(ThirdPartyCertificateTool.java:450)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.main(ThirdPartyCertificateTool.java:511)
CAM-CRP-1240 Unable to build the entire certificate chain. Ensure that the CA certificate file contains the entire CA certificate chain. Reason: java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1422)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter.storeThirdPartyCamCryptoCert(KeyStoreWriter.java:1250)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.installCamCryptoKeyCert(ThirdPartyCertificateTool.java:450)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.main(ThirdPartyCertificateTool.java:511)
Caused by: java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at org.bouncycastle145.jce.provider.PKIXCertPathBuilderSpi.engineBuild(PKIXCertPathBuilderSpi.java:112)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1418)
        ... 3 more
java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at org.bouncycastle145.jce.provider.PKIXCertPathBuilderSpi.engineBuild(PKIXCertPathBuilderSpi.java:112)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1418)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter.storeThirdPartyCamCryptoCert(KeyStoreWriter.java:1250)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.installCamCryptoKeyCert(ThirdPartyCertificateTool.java:450)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.main(ThirdPartyCertificateTool.java:511)
java.security.cert.CertPathBuilderException: No issuer certificate for certificate in certification path found.
        at org.bouncycastle145.jce.provider.PKIXCertPathBuilderSpi.engineBuild(PKIXCertPathBuilderSpi.java:112)
        at java.security.cert.CertPathBuilder.build(Unknown Source)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter._orderCertChain(KeyStoreWriter.java:1418)
        at com.cognos.accman.jcam.crypto.misc.KeyStoreWriter.storeThirdPartyCamCryptoCert(KeyStoreWriter.java:1250)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.installCamCryptoKeyCert(ThirdPartyCertificateTool.java:450)
        at com.cognos.accman.jcam.utilities.ThirdPartyCertificateTool.main(ThirdPartyCertificateTool.java:511)

Entire configuration is to configure the WebSphere Liberty Profile web application server to server https.  In fundamental of web server SSL configuration, the entire SSL certificate chain has to be imported into the Java trust store, and not just the certificate the issue to the machine itself.

Following is the background info and preparation:
1. Backup all certificate files used by Cognos Configuration Manager in COGNOS_HOME\configuration\certs\
2. Ensure JAVA_HOME is not set, or set it to COGNOS_HOME\jre.  Do not use other Java for compatibility with Cognos, or you would be getting other SSL issue
3. Cognos Configuration Manager used SSL stores in COGNOS_HOME\configuration\certs, and not COGNOS_HOME\jre\lib\security\
4. This key store is a Java JKS key store, full name is COGNOS_HOME\configuration\certs\\CAMKeystore.jks
5. SSL verification can use keytools as it is pure Java keystore

Following is the resolution where CA root certificate, and intermediate CA certificate both are not in the Java keystore:
1. Uses Windows Explorer to open up the CA certificate that issue SSL certificate to Cognos server.  This is called intermediate cert.  This intermediate cert is the CA certificate Cognos document provided instruction to import it, but it will fail
2. For paid SSL certificate, this SSL certificate will be the vendor's intermediate certificate.  For example, DigiCert's SHA2 based CA cert will look below:

 3. Click on the last tab label "Certification Path" to see the CA chain.  In this scenario, there is just 1 intermediate CA certificate, and 1 root certificate.  If there are multiple intermediate certs, then all of them will need to be imported

4. Double click on the parent cert, in this case the root cert.  This will be how it looks like

3. Export out this root cert from Details tab.  Click on button "Copy to File..."

4. "Certificate Export Wizard" will run, and following the screen to create "Base-64 encoded X.509 (.CER)" file.  The filename can be any extension as Java doesn't care about its extension

5. If there are multiple intermediate CA cert, then repeat this for each of them.  You will have 1 CER file for each CA cert

6. Import the root CA cert first using this command.  For some reason, this command is shown as the last step in Cognos' document:
ThirdPartyCertificateTool.bat -E -T -r D:\DigiCert\digicert_root.cer -p NoPassWordSet
ThirdPartyCertificateTool.bat -E -T -r D:\DigiCert\digicert_intermediate1.cer -p NoPassWordSet
(if there are more intermediate SSL cert)
ThirdPartyCertificateTool.bat -E -T -r D:\DigiCert\digicert_intermediate2.cer -p NoPassWordSet
ThirdPartyCertificateTool.bat -E -T -r D:\DigiCert\digicert_intermediate3.cer -p NoPassWordSet

7. Lastly, import the CA cert issued the SSL certificate to the Cognos server together with the crypto cert
ThirdPartyCertificateTool.bat -i -e -r crypto.cer -p NoPassWordSet -t cacert.pem

8. If immediate CA cert is already imported into trust store, then there will be a warning message to tell you it already exists, but it will continue to import the crypto cert.  Just ignore the warning

9. Verify that entire SSL certificate are imported by using the fingerprint/thumbprint, or serial number:

%java_home%\bin\keytool -list -keystore COGNOS_HOME\configuration\certs\CAMKeystore.jks -storepass NoPassWordSet -storetype JKS

10. Uses this command to find the issuer's name for root certificate
%java_home%\bin\keytool -list -keystore COGNOS_HOME\configuration\certs\CAMKeystore.jks -storepass NoPassWordSet -storetype JKS | find "Issuer: CN=" | find "Root"

11. Uses this command to find by fingerprint
%java_home%\bin\keytool -list -keystore COGNOS_HOME\configuration\certs\CAMKeystore.jks -storepass NoPassWordSet -storetype JKS | find "59:0D:2D:7D:88:4F:40:2E:61:7E:A5:62:32:17:"