Prepare files for enabling secure communication
Before you begin:
- Make sure that aJava™ Runtime Environment is installed on your machine and that the JAVA_HOME variable is defined in the Environment variables. For more information, see the Java requirements section.
- Make sure that you obtain a signed certificate from a certificate authority (CA) and
that you have its root certificate.Note: In case you don't want to use a CA signed certificate, you can use a self-signed certificate instead. For more information, see (Optional) Generate a self-signed key certificate.
Keystore requirements
- A
PrivateKeyEntry
of the CA signed certificate. - A
TrustedCertEntry
of the root CA certificate.
keytool -keystore "<server_keystore.p12>" -import -file "<path_to_certificate>" -alias "<alias_name>"
.jks
) or PKCS12 (.p12
) format.
However, it is recommended to use PKCS12, which is an industry standard format. JKS keystores can be
migrated to PKCS12 with the following
command:keytool -importkeystore -srckeystore <server_keystore.jks> -destkeystore "<server_keystore.p12>" -deststoretype pkcs12
(Optional) Generate a self-signed key certificate
- At your convenience, use any tool to generate the certificates in a dedicated location. For example, C:\certificates.
- Use the Java
keytool
utility with the following input to generate private and public key (key pair):keytool -genkeypair -alias "<hostname>" -keyalg RSA -keysize 2048 -dname "cn=<hostname>" -ext BasicConstraints:critical=ca:true -keypass "<password>" -keystore "<server_keystore.p12>" -storepass "<password>" -storetype PKCS12
Notes:The generated key is in the specified keystore.- The distinguished name (
-dname
) and Subject Alternative Name (SAN
) must match the hostname of the machine that it is associated. Otherwise, the hostname verification fails. - The value of the Common Name (CN) is recommended to be a Fully Qualified Domain Name (FQDN). For example, addi-server.my-company.com, which is the industry standard.
- The value of the Subject Alternative Name (SAN) must be set and equal to the value of
CN. You need to add SAN requirements by using the commands
-ext "san=dns:<DNS_VALUE>"
and-ext "san=ip:<IP_ADDRESS>"
- The certificate Enhanced Key Usage needs to be set to both server and client authentication.
- The distinguished name (
- Export the
certificate.
keytool -exportcert -alias "<hostname>" -keystore "<server_keystore.p12>" -file "server_certificate.crt" -storepass "<password>"
- Check the folder where the certificates were created. Both keystore and certificate files need to be there.
Export the certificate and private key
Currently, the IBM ADDI Build Client, IBM AD File Service, and Authentication Server (DEX) require the certificate and private key to be in external files. Complete the following steps to prepare those files:
- Use the OpenSSL tool from Cygwin to export the certificates in a dedicated location. For example, C:\certificates.
- To generate the server.key file, run the following command.
openssl pkcs12 -in "<server_keystore.p12>" -nocerts -nodes -out server.key
- To generate the server_certificate.crt file, run the following command.
keytool -list -keystore "<server_keystore.p12>" -alias "<hostname>" -rfc > "<server_certificate.crt>"
- Check the folder where the certificates were created. Both server.key and server_certificate.crt files need to be there.
Import the certificate to the Trusted Root Certificate Authorities
- On WindowsWindows:
- Right-click the certificate and then click Install Certificate.
- Select Local Machine and click Next.
- Select Place all certificates in the following store.
- Click Browse... Import the certificate to Root Certificate Authorities.
- Click OK and then Next.
- Click Finish to complete the certificate import wizard.
Import the certificate to the Java runtime keystore
The root CA certificate or the self signed certificate must be installed into the local machine's
Java
cacerts
keystore. A certificates file named cacerts
resides in the
security properties directory, java.home\jre\lib\security, where
java.home
is the Java runtime environment
directory (the jre
directory in the SDK or the top-level directory of the Java 2 Runtime Environment).
The cacerts
file represents a system-wide keystore with CA certificates. System
administrators can configure and manage that file by using keytool
, specifying
jks
as the keystore type. The cacerts
keystore file ships with
several root CA certificates. The initial password of the cacerts
keystore file is
changeit
. System administrators need to change that password and the default access
permission of that file when they install the SDK.
- Open a Command Prompt (on Windows) or a Terminal (on Linux®) and go to the folder that contains the newly prepared server_keystore.p12.
- Execute the following command to import all certificates from
server_keystore.p12 to the Java's
cacerts keystore.
keytool -importkeystore -srckeystore "<server_keystore.p12>" -srcstorepass "<server_keystore_password>" -destkeystore "%JAVA_HOME%\jre\lib\security\cacerts" -deststorepass "<cacerts_password>"
Note: The default cacerts password ischangeit
.