Page History
...
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.
Anchor | ||||
---|---|---|---|---|
|
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
# 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 |
Anchor | ||||
---|---|---|---|---|
|
For a given server the second step includes to create a private key and Certificate Signing Request (CSR). The resulting server certificate will be signed.
...
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.
Code Block | ||||
---|---|---|---|---|
| ||||
[ 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 |
...
The sub-directories certs
, csr
and private
will be created from the below scripts should they not exist.
...
Creating the Root CA Certificate
The following files will be created:
...
This step is performed just once. In case of repeated execution a new renewal of the Root CA Certificate will be created and any server certificates will have to be renewed.
...
Code Block | ||||
---|---|---|---|---|
| ||||
./create_root_ca.sh |
...
Creating a Server Certificate
The following files will be created with <server>
being a placeholder for the hostname of the indicated serverfor which a certificate should be created.
<ca>/certs/<server>.crt
<ca>/certs/<server>.csr
<ca>/private/<server>.key
...
- Download: create_certificate.sh
- The shell script is executed with two arguments:
- The DNS hostname of the server that should receive 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.
- The lifetime of the certificate is specified by the number of days.
...