You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

Introduction

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

  • CA-signed certificates are issued by a known and trusted Certificate Authority (CA) that validates the domain owner.
  • Self-signed certificates are created by the user and are not related to a known CA.

There is no difference concerning the type of X.509 certificates, the usage for Server Authentication / Client Authentication, or the encryption of connections.

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.

Creating the Root CA Certificate

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.

Create Root CA Certificate
# step 1 Generate Certificate Authority (CA) Private Key
openssl ecparam -name prime256v1 -genkey -noout -out root-ca.key

# step 2: Generate Certificate Authority Certificate
openssl req -new -x509 -sha256 -key root-ca.key -out root-ca.crt

Creating a Server Certificate

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:

Create Server Certificate
# 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' -nodes \
    -days 7300 -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:${SERVER}\nnsCertType = client, server\nkeyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment\nextendedKeyUsage = serverAuth, clientAuth\n")


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.

  • Replace the value of the commonName attribute with the hostname of the server for which the certificate should be created.
  • Adjust other attributes in the [ standard_dn ] section to your needs.

OpenSSL configuration file openssl-cert.config
[ 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.

The shell script is executed without arguments.

Run .create_root_ca.sh shell script
./create_root_ca.sh

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.

Run .create_certificate.sh shell script
# ./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 to establish secure connections.
  • --days
    • The lifetime of the certificate is specified by the number of days.



  • No labels