Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

Users have a choice to use CA-signed certificates and self-signed certificates:

SSL/TLS Certificates are used to secure HTTP connections between JOC Cockpit, Controller and Agents, for example JS7 - JOC Cockpit HTTPS Connections.

Users can choose one of the approachs specified with RFC5280:

  • Self-issued Certificates are created individually per user and are not applicable within reasonable effort for deploying individual certificate files to JS7 products.
  • Private CA-signed Certificates are issued by users who operate their own Private Certificate Authority (CA).
  • Public CA-signed Certificates are issued by a CA-signed certificates are issued by a known and trusted Certificate Authority (CA) that validates the domain owner. Self-signed certificates They are not created by the user users but are purchased from the trusted CA and are not related to a known CAin scople of this article.

There is no difference concerning the type in using a Private CA or Public CA concerning functionality of X.509 certificates, the usage for Server Authentication / Client Authentication, or the encryption security of connections. The only difference is that users trust the Private CA that they set up on their own.

Examples in the article make use of JS7 Release 2.7.2, OpenSSL 1.1.1k  FIPS 25 Mar 2021 for Unix and OpenSSL 3.1.4 24 Oct 2023 for Windows. OpenSSL ships with Linux & other Unix OS The article explains how to create self-signed certificates by use of OpenSSL. This utility ships with Linux and most Unix environments and is available for Windows environments. The below examples are focused on Unix.

Setting up the Private CA

Anchor

...

creating_private_key_and_csr
creating_private_key_and_csr
Creating the Private Key and Certificate Signing Request

Users have the option to use ECDSA or RSA for the encryption type applied to the Private Key.

Users can run the following commands from the shell and replace the value of the ca_key_name environment variable with a name of their choice that is used when creating related files.

Anchor
using_ca_private_key_ecdsa
using_ca_private_key_ecdsa
Using ECDSA Encryption

The first step includes to create the root-ca.key private key file and the root-ca.crt self-signed certificate file for the Root CA both in PEM format. This step is performed just once.

Code Block
languagebash
titleCreate Root CA CertificateExample how to create Private Key and Certificate Signing Request using ECDSA encryption (Unix)
linenumberstrue
# GenerateSpecify Rootkey Certificatename Authorityused (CA)for Private file names
ca_key_name=root-ca

# Create Private Key
openssl ecparam -name prime256v1genkey -genkeyname -nooutsecp384r1 -out root-ca${ca_key_name}.key

# GenerateCreate RootCertificate CASigning CertificateRequest
openssl req -new -x509sha512 -sha256 -days 5475nodes \
    -key root-ca${ca_key_name}.key -out root-ca.crt

# You are about to be asked to enter information that will be incorporated
# into your certificate request.
# What you are about to enter is what is called a Distinguished Name or a DN.
# There are quite a few fields but you can leave some blank
# For some fields there will be a default value,
# If you enter '.', the field will be left blank.
# -----
# Country Name (2 letter code) [XX]:DE
# State or Province Name (full name) []:Berlin
# Locality Name (eg, city) [Default City]:Berlin
# Organization Name (eg, company) [Default Company Ltd]:SOS
# Organizational Unit Name (eg, section) []:JS7
# Common Name (eg, your name or your server's hostname) []:JS7 Deployment CA
# Email Address []:

# Alternative: Generate Root Certificate Authority (CA) Private Key using passphrase
openssl ecparam -genkey -name secp256k1 | openssl ec -aes256 -passout pass:jobscheduler -out root-ca.key

 # Generate Root CA Certificate
openssl req -new -x509 -sha256 -days 5475 -key root-ca.key -passin pass:jobscheduler -out root-ca.crt
Code Block
languagebash
titleAlternative: Create Root CA Certificate using passphrase
linenumberstrue
# Generate Root Certificate Authority (CA) Private Key using passphrase
openssl ecparam -genkey -name secp256k1 | openssl ec -aes256 -passout pass:jobscheduler -out root-ca.key

 # Generate Root CA Certificate
openssl req -new -x509 -sha256 -days 5475 -key root-ca.key -passin pass:jobscheduler -out root-ca.crt

Explanation:

As a response to the second command the OpenSSL utility prompts for a number of specifications for the Distinguished Name, i.e. the unique name of the Root CA Certificate:

  • Country Name: a 2 letter country code is expected as stated for example with https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  • State or Province Name: the name of a state is expected
  • Locality Name:  the name of a city is expected
  • Organization Name: arbitrary input is allowed
  • Organizational Unit Name: arbitrary input is allowed
  • Common Name: an arbitrary name can be chosen as the name of the Root CA
  • Email Address: empty input is allowed

...

For a given server the next steps includes to create a private key and Certificate Signing Request (CSR). The resulting server certificate will be signed. 

This step is performed for each server certificate that should be created.

Run the following commands from a bash shell and replace the value of the server variable with the hostname or FQDN for which the certificate should be created:

\
    -out ${ca_key_name}.csr \
    -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=${ca_key_name}"
Expand
titleWindows version...
Code Block
languagetext
titleExample how to create Private Key and Certificate Signing Request using ECDSA encryption (Windows)
linenumberstrue
@rem Specify key name used for file names
set ca_key_name=root-ca
 
@rem Create Private Key
openssl ecparam -genkey -name secp384r1 -out %ca_key_name%.key
 
@rem Create Certificate Signing Request 
openssl req -new -sha512 -nodes ^
    -key %ca_key_name%.key ^
    -out %ca_key_name%.csr ^
    -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=%ca_key_name%"
Expand
titleExplanations...
  • Users should adjust the ca_key_name environment variable specifying a value that matches the purpose such as root-ca for a Root CA Certificate.
  • Private Key
    • Choice of algorithm such as secp256k1, secp384r1 depends on support by the Java version used with JS7.
  • Certificare Signing Request
    • The hash algorithm such as -sha256, -sha512 can be freely chosen.
    • The -subj option specifies the Distinguished Name used for the subject of the CSR and resulting Certificate.
      • The Distinguished Name is a unique identifier frequently using the hierarchy of Country C, State ST, Location L, Organization O, Organizational Unit OU and Common Name CN.
      • For the Private Root CA Certificate the subject and issuer properties of the CSR/Certificate are the same. The minimum requirement is to specify the Common Name CN=<name> where <name> can freely be chosen.
      • For Private CA-signed Certificates the subject property holds the Certificate's Distinguished Name and the issuer property holds the Private CA Certificate's Distinguished Name using different values.
  • The following files will be created with this step:
    • The root-ca.key file will hold the Private Key.
    • The root-ca.csr file will hold the Certificate Signing Request.

Anchor
using_ca_private_key_rsa
using_ca_private_key_rsa
Using RSA Encryption

Expand
titleClick to expand/collapse...
Code Block
languagebash
titleExample how to create Private Key and Certificate Signing Request using RSA encryption (Unix)
linenumberstrue
# Specify key name used for file names
ca_key_name=root-ca

# Create Private Key and Certificate Signing Request
openssl req -new -newkey rsa:4096 -sha256 -nodes \
    -keyout ${ca_key_name}.key \
    -out ${ca_key_name}.csr \
    -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=${ca_key_name}"
Expand
titleWindows version...
Code Block
languagetext
titleExample how to create Private Key and Certificate Signing Request using RSA encryption (Windows)
linenumberstrue
@rem Specify key name used for file names
set ca_key_name=root-ca
 
@rem Create 
Code Block
languagebash
titleCreate Server Certificate
linenumberstrue
# Specify server for which the certificate should be created server=somehost # Step 1 - Generate
Private Key and Certificate Signing Request
openssl req -new -
config openssl-cert.config -extensions 'standard exts'
newkey rsa:4096 -sha256 -nodes 
\
^
    
-days 5475 -newkey rsa:4096 -keyout ${server}.key -out ${server}.csr # Step 2 - Generate and sign the Server Certificate openssl x509 -req \ -in ${server}.csr \ -CA root-ca.crt \ -CAkey root-ca.key \ -CAcreateserial \ -out ${server}.crt -days 7300 \ -extfile <(printf 'subjectAltName=DNS:%s\nnsCertType = client, server\nkeyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment\nextendedKeyUsage = serverAuth, clientAuth\n' "${server}")

Explanation:

  • The following files will be created for the given server:
    • <server>.key: the Private Key
    • <server>.csr: the Certificate Signing Request
    • <server>.crt: the Server Certificate
  • For operation with JS7 JOC Cockpit, Controller and Agents users can add
    • the Private Key and Server Certificate to a keystore.
    • the Root CA Certificate to a truststore.
  • For details see JS7 - How to add SSL TLS Certificates to Keystore and Truststore

In order to run the script successfully the following openssl-cert.config file has to be present. To create a Server Certificate the CommonName attribute has to be adjusted.

...

-keyout %ca_key_name%.key ^
    -out %ca_key_name%.csr ^
    -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=%ca_key_name%"
Expand
titleExplanations...
  • In the example the Private Key is created using the specified key size 4096.
  • For use of the -sha256 hash algorithm and -subj option see Using ECDSA Encryption.
  • The following files will be created with this step:
    • The root-ca.key file will hold the Private Key.
    • The root-ca.csr file will hold the Certificate Signing Request.

Anchor
creating_ca_certificate
creating_ca_certificate
Creating the CA Certificate

Steps include to create the root-ca.crt Private CA-signed Certificate file in PEM format.

Users can run the following commands from the shell and replace the value of the ca_key_name environment variable with a name of their choice that is used when creating related files.

Code Block
languagebash
titleExample how to create CA Certificate (Unix)
linenumberstrue
# Specify key name used for file names
ca_key_name=root-ca

# Create Certificate
openssl x509 -req -sha512 -days 7305 \
    -signkey ${ca_key_name}.key \
    -in ${ca_key_name}.csr \
    -out ${ca_key_name}.crt \
    -extfile <(printf "basicConstraints=CA:TRUE\nkeyUsage=critical,nonRepudiation,keyCertSign,cRLSign\n")
Expand
titleWindows version...
Code Block
languagetext
titleExample how to create CA Certificate (Windows)
linenumberstrue
@rem Specify key name used for file names
set ca_key_name=root-ca
 
@rem Create Certificate
set ca_csr_tmp_file=ca-csr-%RANDOM%.tmp
copy /Y NUL %ca_csr_tmp_file%
echo basicConstraints=CA:TRUE >> %ca_csr_tmp_file%
echo keyUsage=critical,nonRepudiation,keyCertSign,cRLSign >> %ca_csr_tmp_file%

openssl x509 -req -sha512 -days 7305 ^
    -key %ca_key_name%.key ^
    -in %ca_key_name%.csr ^
    -out %ca_key_name%.crt ^
    -extfile %ca_csr_tmp_file%

del /q %ca_csr_tmp_file%
Expand
titleExplanations...
  • The SHA option such as -sha256, -sha384, -sha512 can be freely chosen.
  • The -days option specifies the validity period of the CA Certificate that should be longer than the validity period of individual certificates signed by the CA later on.
  • The -signkey option specifies the location of the Private Key file created from the previous step.
  • The -in option specifies the location of the Certificate Signing Request file created from the previous step.
  • The -out option specifies the location of the resulting Certificate file.
  • The -extfile option specifies the Basic Constraint CA:TRUE which is required for a CA Certificate. Key Usage is limited to signing certificates.
  • The following files will be created with this step:
    • The root-ca.crt file will hold the CA Certificate.

Creating SSL/TLS Server Certificates

For a given server next steps includes to create the Private Key and Certificate Signing Request (CSR). The resulting Server Certificate will be signed by the Private CA. 

This step is performed for each Server Certificate that should be created.

Users can run the following commands from the shell and replace the value of the server_name environment variable with a name of their choice that is used when creating related files.

Creating the Private Key and Certificate Signing Request

Anchor
using_server_private_key_ecdsa
using_server_private_key_ecdsa
Using ECDSA Encryption

Code Block
languagebash
titleExample how to create Private Key and Certificate Signing Request using ECDSA encryption (Unix)
linenumberstrue
# Specify key name used for file names
server_name=myhost

# Create Private Key
openssl ecparam -genkey -name secp384r1 -out ${server_name}.key

# Create Certificate Signing Request
openssl req -new -sha512 -nodes \
    -key ${server_name}.key \
    -out ${server_name}.csr \
    -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=${server_name}" 
Expand
titleWindows version...
Code Block
languagetext
titleExample how to create Private Key and Certificate Signing Request using ECDSA encryption (Windows)
linenumberstrue
@rem Specify key name used for file names
set server_name=myhost

@rem Create Private Key
openssl ecparam -genkey -name secp384r1 -out %server_name%.key

@rem Create Certificate Signing Request
openssl req -new -sha512 -nodes ^
    -key %server_name%.key ^
    -out %server_name%.csr ^
    -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=%server_name%"
Expand
titleExplanations...

Anchor
using_server_private_key_rsa
using_server_private_key_rsa
Using RSA Encryption

Expand
titleClick to expand/collapse...
Code Block
languagebash
titleExample how to create Private Key and Certificate Signing Request using RSA encryption (Unix)
linenumberstrue
# Specify key name used for file names
server_name=myhost

# Create Private Key and Certificate Signing Request
openssl req -new -newkey rsa:4096 -sha256 -nodes \
    -keyout ${server_name}.key \
    -out ${server_name}.csr \
    -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=${server_name}"
Expand
titleWindows version...
Code Block
languagetext
titleExample how to create Private Key and Certificate Signing Request using RSA encryption (Windows)
linenumberstrue
@rem Specify key name used for file names
set server_name=myhost

@rem Create Private Key and Certificate Signing Request
openssl req -new -newkey rsa:4096 -sha256 -nodes ^
    -keyout %server_name%.key ^
    -out %server_name%.csr ^
    -subj "/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=%server_name%"
Expand
titleExplanations...

Creating the Server Certificate

Code Block
languagebash
titleExample how to create and sign Server Certificate (Unix)
linenumberstrue
# Specify server for which the certificate should be created
server_name=myhost

# Create and sign Server Certificate
openssl x509 -req -sha512 -days 3652 \
    -in ${server_name}.csr \
    -CA root-ca.crt \
    -CAkey root-ca.key \
    -CAcreateserial \
    -out ${server_name}.crt \
    -extfile <(printf 'subjectAltName=DNS:%s\nkeyUsage=critical,keyEncipherment,digitalSignature\nextendedKeyUsage=serverAuth,clientAuth\n' "${server_name}")
Expand
titleWindows version...
Code Block
languagetext
titleExample how to create and sign Server Certificate (Windows)
linenumberstrue
@rem Specify key name used for file names
set server_name=myhost

@rem Create and sign Server Certificate
set server_crt_tmp_file=server-crt-%RANDOM%.tmp
copy /Y NUL %server_crt_tmp_file%
echo subjectAltName=DNS:%server_name% >> %server_crt_tmp_file%
echo keyUsage=critical,keyEncipherment,digitalSignature >> %server_crt_tmp_file%
echo extendedKeyUsage=serverAuth,clientAuth >> %server_crt_tmp_file%
 
openssl x509 -req -sha512 -days 3652 ^
    -in %server_name%.csr ^
    -CA root-ca.crt ^
    -CAkey root-ca.key ^
    -CAcreateserial ^
    -out %server_name%.crt ^
    -extfile %server_crt_tmp_file%

del /q %server_crt_tmp_file%
Expand
titleExplanations...
  • The following files will be created for the given server:
    • myhost.crt: the Server Certificate
  • For operation with JS7 JOC Cockpit, Controller and Agents users can add

Resources

Shell Scripts

As an alternative to running OpenSSL commands in an interactive shell, scripts are provided that perform this task.

The below scripts assume the following directory layout:

  • <ca>  The directory <ca> is a placeholder. Any directory can be used.
    • create_root_ca.sh
    • create_server_certificate.sh
    • certs
    • csr
    • private

The sub-directories certs, csr and private will be created should they not exist.

Creating the Private Root CA Certificate

Download: create_root_ca.sh

The following files will be created when executing the script:

  • <ca>/certs/root-ca.crt
  • <ca>/csr/root-ca.csr
  • <ca>/private/root-ca.key

This step is performed just once. In case of renewal of the Root CA Certificate any Server Certificates will have to be renewed.

Code Block
languagebash
titleRun .create_root_ca.sh shell script
linenumberstrue
# Description
# create_root_ca.sh --key-name=<basename> --subject=<distinguished-name> --days=<number-of-days>

# Example for use with defaults
./create_root_ca.sh

# Example for use with basename
./create_root_ca.sh --key-name=ca-root

# Example applying specific distinguished name and lifetime
./create_root_ca.sh --subject="/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=JS7 CA" --days=7660


The shell script is optionally executed with the following arguments:

  • --key-name
    • The basename of the key without extension. Default: root-ca
  • --subject
    • The distinguished name that is used as the subject of the CA Certificate. Default: /C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=Root CA
  • --days
    • The lifetime of the certificate is specified by the number of days. Default: 7305
    • Consider that Server Certificates have to be renewed if the Root CA Certificate expires.

Creating a Server Certificate

Download: create_server_certificate.sh

The following files will be created with <server> being a placeholder for the hostname for which a certificate should be created.

  • <ca>/certs/<server>.crt
  • <ca>/csr/<server>.csr
  • <ca>/private/<server>.key

This step is performed for each Server Certificate that should be created.

Code Block
languagebash
titleRun .create_server_certificate.sh shell script
linenumberstrue
# Description
# create_server_certificate.sh --dns=<hostname>[,<hostname>] --key-name=<basename> --subject=<distinguished-name> --days=<number-of-days>

# Example for use with DNS and lifetime
./create_server_certificate.sh --dns=centostest-primary --days=365

# Example for use with DNS, key name and lifetime
./create_server_certificate.sh --dns=centostest-primary,centostest-primary.sos --key-name=centostest-primary --days=4017

# Example for use with DNS, subject and lifetime
./create_server_certificate.sh --dns=centostest-primary,centostest-primary.sos --subject="/C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=centostest-primary.sos" --days=4017 


The shell script is executed with the following arguments:

  • --dns (required)
    • The DNS hostname of the server that should be assigned the certificate. A server can be assigned more than one DNS hostname, for example the FQDN can extend the hostname. Only DNS hostnames that are added to the certificate can be used later on to establish secure HTTPS connections.
  • --key-name
    • The basename of the key without extension. Default: root-ca
  • --subject
    • The distinguished name that is used as the subject of the Server Certificate. Default: /C=DE/ST=Berlin/L=Berlin/O=SOS/OU=IT/CN=<dns>
    • The CN attribute must specify the server's hostname. By default the first hostname specified with the --dns option is used
Code Block
titleOpenSSL configuration file openssl-cert.config
linenumberstrue
[ req ]
prompt             = no
distinguished_name = standard dn

[ standard dn ]
            commonName = somehost
           countryName = DE
          localityName = Berlin
      organizationName = SOS
organizationalUnitName = JS7
   stateOrProvinceName = Berlin

[ standard exts ]
extendedKeyUsage = serverAuth,clientAuth

Resources

Shell Scripts

As an alternative to running OpenSSL commands in an interactive shell a few scripts are provided that perform this task.

The below scripts assume the following directory layout:

  • <ca>  The directory <ca> is a placeholder. Any directory can be used.
    • create_root_ca.sh
    • create_certificate.sh
    • certs
    • csr
    • private

The sub-directories certs, csr and private will be created from the below scripts should they not exist.

Creating the Root CA Certificate

Download: create_root_ca.sh

The following files will be created:

  • <ca>/certs/root-ca.crt
  • <ca>/private/root-ca.key

This step is performed just once. In case of renewal of the Root CA Certificate any Server Certificates will have to be renewed.

Code Block
titleRun .create_root_ca.sh shell script
linenumberstrue
# Description
# create_root_ca.sh --days=<number-of-days>

# Example
./create_root_ca.sh --days=5475

The shell script is executed with an optional single argument:

  • --days
    • The lifetime of the certificate is specified by the number of days (default: 5475, matching approx. 15 years).
    • Consider that server certificates have to be renewed if the Root CA Certificate expires.

Creating a Server Certificate

Download: create_certificate.sh

The following files will be created with <server> being a placeholder for the hostname for which a certificate should be created.

  • <ca>/certs/<server>.crt
  • <ca>/certs/<server>.csr
  • <ca>/private/<server>.key

This step is performed for each Server Certificate that should be created.

Code Block
titleRun .create_certificate.sh shell script
linenumberstrue
# Description
# create_certificate.sh --dns=<server-hostname>[,<server-hostname>] --days=<number-of-days>

# Example
./create_certificate.sh --dns=apmaccs,apmaccs.sos --days=365

The shell script is executed with two arguments:

  • --dns
    • The DNS hostname of the server that should be assigned the certificate. A server can be assigned more than one DNS hostname, for example the FQDN can extend the hostname. Only DNS hostnames that are added to the certificate can be used later on to establish secure HTTPS connections.
  • --days
    • The lifetime of the certificate is specified by the number of days (default: 5475, matching approx. 15 years).. Default: 3652