HTTPS server certificate

HTTPS server certificate

This article explains how to replace the default self-signed certificate of InterformNG2 with a certificate issued by a trusted certificate authority (CA). When the certificate is set up correctly, browsers and other systems that connect to InterformNG2 over HTTPS can validate the connection without warnings.

This guide uses OpenSSL for the certificate workflow. The same result can be achieved with other tools, such as Java keytool. The exact certificate request and issuance procedure may vary between certificate authorities; follow your CA's instructions where applicable.

Tested on: The procedure was carried out on InterformNG2 4.1.1 on Windows Server 2022. Paths and commands below use the default Windows installation folder.

How it works

An HTTPS server certificate always consists of two parts that belong together: a private key, which stays on your side, and the certificate, which the CA issues for that key. InterformNG2 needs both parts, together with the CA's intermediate certificates, in one PKCS#12 file (.p12). The overall flow is:

Private key > CSR > CA issues certificate and chain > Verify key/certificate match > Create PKCS#12 file > Verify PrivateKeyEntry > Configure InterformNG2 > Restart > Test HTTPS

Important: Keep the private key that you use to create the certificate request (CSR). The certificate that the CA issues works only together with that exact private key. If the private key is lost, or does not match the certificate, you must create a new private key and CSR and have the certificate re-issued.

Prerequisites

  • Administrator access to the server where InterformNG2 is installed.
  • The host name (fully qualified domain name) that browsers and other systems use to reach InterformNG2. The certificate must be issued for this host name, and clients must connect using this host name.
  • An account with a certificate authority that can issue a TLS/SSL server certificate.
  • OpenSSL installed on the server or on another secure machine. The files do not have to be created on the InterformNG2 server, but all files must be kept together in a secure folder.
  • Java keytool. It is included in the InterformNG2 installation: C:\Program Files\InterFormNG2\jre\bin\keytool.exe
  • A backup of the current keystore folder and of the file application-default.properties.

Procedure

In the examples below, the private key is called interform.key, the certificate from the CA server.crt, the CA bundle ca-bundle.crt, and the new keystore interformng2-ca.p12. Replace the names with your own. Run the commands in a Command Prompt opened as administrator, in the folder that holds the files.

InterformNG2 needs a PKCS#12 keystore file, which normally has the extension .p12 or .pfx. If you already have that, then you can jump directly to step 6 in the procedure below.

Note: The OpenSSL commands assume that openssl is available on the PATH. If it is not, use the full path to the OpenSSL executable in quotes, for example "C:\Program Files\OpenSSL-Win64\bin\openssl.exe" genrsa -out interform.key 2048. The path depends on your OpenSSL installation.

Step 1. Generate the private key
openssl genrsa -out interform.key 2048

Check that the private key is valid:

openssl pkey -in interform.key -check -noout

Expected result: Key is valid

Store interform.key in a secure location and include it in your backups. Do not send it to the CA.

Step 2. Create the certificate request (CSR) from the private key
openssl req -new -key interform.key -out interform.csr

OpenSSL asks for the details of the request:

  • Country, state, locality, organisation, organisational unit: your organisation's details.
  • Common Name: the host name from the prerequisites (for example the server's fully qualified domain name).
  • Email address and the extra attributes (challenge password, optional company name): follow your organisation's policy and the requirements of your CA.

Important: Some prompts show an example default value in square brackets, for example Country Name (2 letter code) [AU] or Organization Name (eg, company) [Internet Widgits Pty Ltd]. If you press Enter without typing a value, OpenSSL uses this example value. Always type your own organisation details. To leave a field empty, enter a full stop (.).

Optionally, display the request to check the details before you send it to the CA:

openssl req -in interform.csr -noout -text
Step 3. Obtain the certificate and the chain from the CA

Submit interform.csr to the CA. When the certificate is issued, download:

  • the server certificate for your host name (here server.crt), and
  • the CA bundle with the intermediate certificate(s) (here ca-bundle.crt). CAs often name this file "bundle" or "chain".

Download the files in PEM format (Base64 text, starting with -----BEGIN CERTIFICATE-----).

Step 4. Verify that the certificate matches the private key

Extract the public key from the private key and from the certificate, and compare the two:

openssl pkey -in interform.key -pubout > key-publickey.pem
openssl x509 -in server.crt -pubkey -noout > cert-publickey.pem
fc cert-publickey.pem key-publickey.pem

Expected result: FC: no differences encountered - the two public-key files are identical. If they differ, the certificate was not issued for this private key. Do not continue; see Troubleshooting.

Optionally, check the certificate subject, the issuer and the validity period of the certificate:

openssl x509 -in server.crt -noout -subject -issuer -dates
Step 5. Create the PKCS#12 file
openssl pkcs12 -export -out interformng2-ca.p12 ^
-inkey interform.key -in server.crt ^
-certfile ca-bundle.crt -name interform

The ^ character continues the command on the next line in the Windows Command Prompt. You can also enter the command on one line without it.

  • -inkey adds the private key, -in the server certificate, and -certfile the CA chain.
  • -name sets the alias of the entry in the keystore (here interform).
  • When prompted, enter an export password. Use at least 6 characters, because keytool rejects shorter keystore passwords. This password protects both the keystore and the private key; PKCS#12 keystores do not use a separate key password.
Step 6. Verify that the PKCS#12 file contains a PrivateKeyEntry
"C:\Program Files\InterFormNG2\jre\bin\keytool" -list -keystore interformng2-ca.p12

Enter the keystore password when prompted. Expected result: the keystore contains 1 entry, and the entry type is PrivateKeyEntry:

Example - correct result:

Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 1 entry

interform, <creation date>, PrivateKeyEntry,
Certificate fingerprint (SHA-256): <fingerprint>

To see the full certificate chain, add -v. The server certificate is listed first, followed by the CA certificates from the bundle.

"C:\Program Files\InterFormNG2\jre\bin\keytool" -list -v -keystore interformng2-ca.p12

Important: If the entry type is trustedCertEntry, or the keystore contains 0 entries, the file has no private key and cannot be used as an HTTPS server certificate. Do not configure it in InterformNG2.

Example - incorrect result (output with -v):

Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: interform
Creation date: <creation date>
Entry type: trustedCertEntry

Owner: CN=<intermediate CA certificate>

The entry type trustedCertEntry shows that the file contains a certificate without a private key.

Step 7. Copy the file to InterformNG2

Copy interformng2-ca.p12 to the keystore folder of the installation:

C:\Program Files\InterFormNG2\keystore\

Use a new file name. Keep the existing files, so that you can return to the previous configuration if needed.

Step 8. Configure InterformNG2

Open C:\Program Files\InterFormNG2\application-default.properties in a text editor and set the following values:

server.ssl.key-store-type=PKCS12
server.ssl.key-store=keystore/interformng2-ca.p12
server.ssl.key-store-password=<your keystore password>
server.ssl.key-alias=interform

A relative path is resolved from the installation folder. If you enter a full path, write every backslash twice (for example C:\\Certs\\interformng2-ca.p12).

Note: This example uses the alias interform because the PKCS#12 file was created with -name interform.

Step 9. Restart InterformNG2

Restart the service InterformNG2 Service in Windows Services. Wait about a minute and check that the service is still running. If the service stops, check the system log:

C:\ProgramData\InterFormNG2\profiles\default\logs\interformng2.log
Step 10. Verify HTTPS
  • Open https://<host name>:<port> in a browser. Use the host name that the certificate was issued for, and the port configured for InterformNG2.
  • Expected result: the login page opens without a certificate warning. The certificate details show your host name, the CA as issuer, and the expected validity period.
  • Test the connection from each system that connects to InterformNG2 over HTTPS.

Important notes

  • Keystore, not truststore. The server certificate belongs in the PKCS#12 file that server.ssl.key-store points to. Do not import it into the Java truststore (cacerts). cacerts is used when InterformNG2 connects to other systems.
  • Do not import the server certificate as a standalone certificate using keytool -importcert. Importing the certificate on its own creates a trustedCertEntry without the private key. The HTTPS keystore must contain the server certificate together with its corresponding private key and certificate chain.
  • Renewal. CA certificates expire. Plan the renewal before the expiry date and repeat this procedure. Keep the working keystore until the new one is verified.

Troubleshooting

SymptomCause and solution
trustedCertEntry or Your keystore contains 0 entries in the keytool outputThe file has no private key. Create the file again from private key, certificate and chain (Steps 4-6).
The public keys in Step 4 differ, or the private key cannot be foundThe certificate was issued for another key. Create a new private key and CSR (Steps 1-2) and have the certificate re-issued.
keystore password was incorrectThe password does not match the file. If the password of an existing file is unknown, create a new PKCS#12 file.
Keystore password is too short - must be at least 6 charactersUse a password with at least 6 characters.
-keypasswd commands not supportedExpected for PKCS#12 files. The keystore password also protects the key; no action is needed.
An integrity warning appears when you list the keystoreThe password was not entered. Run the command again and enter the keystore password, so that the full contents are shown.
Browser or client still reports an untrusted certificateCheck that the correct file is configured in server.ssl.key-store, that the CA chain was included (-certfile), that the service was restarted, and that you connect with the host name in the certificate.
The service starts and then stops after the changeCheck interformng2.log for the error. Check the path, the password and the alias settings in application-default.properties. To return to the previous state, restore the backup of the properties file.
You see either of these errors in the browser, when you try to access InterformNG2: NET::ERR_CERT_COMMON_NAME_INVALID or SSL_ERROR_BAD_CERT_DOMAIN
Cause: The address in the browser is not in the certificate, for example an IP address, localhost or a short name. Solution: Use the FQDN from the certificate. If clients need another name, reissue the certificate with that name.