Versions Compared

Key

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

...

Code Block
languagebash
titleCreate Root CA Certificate
linenumberstrue
# Generate Root Certificate Authority (CA) Private Key
openssl ecparam -name prime256v1 -genkey -noout -out root-ca.key

# Generate Root CA Certificate
openssl req -new -x509 -sha256 -days 5475 -key root-ca.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 []:

...

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' -nodes \
    -days 73005475 -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}")

...

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.

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


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

...

  • --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).

...