Testing use cases with OpenSSL
Creating a CA with OpenSSL
-
Create the ca_certificate_config.cnf OpenSSL configuration file for the certification authority (CA):
Copy[ req ]
default_bits = 4096
default_keyfile = ca_private_key.pem
distinguished_name = req_distinguished_name
x509_extensions = req_ext
prompt = no
[ req_distinguished_name ]
CN = your CA Name
C = your country
L = your locality
O = your organization
[ req_ext ]
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign -
Generate the RSA private key:
# openssl genpkey –des3 -algorithm RSA -out ca_private_key.pem \-pkeyopt rsa_keygen_bits:4096
-
Extract the public key:
# openssl rsa -in ca_private_key.pem -pubout -out ca_public_key.pem
-
Generate an autosigned root certificate (10-year validity period):
# openssl req -x509 -new -key ca_private_key.pem -out ca_certificate.pem -days 3650 \-config ca_certificate_config.cnf
-
Check the root certificate:
# openssl x509 -in ca_certificate.pem -text -noout
-
Move the certificate file (ca_certificate.pem) and the private key (ca_private_key.pem) to the /etc/stormshield/pki directory.
Issuing a mTLS certificate with a CSR
-
Generate the related mtls_client_csr.cnf CSR configuration file:
Copy[ req ]
distinguished_name = req_distinguished_name
req_extensions = req_ext
string_mask = utf8only
prompt = no
[ req_distinguished_name ]
C = your country
L = your locality
O = your organization
CN = your common name
[ req_ext ]
keyUsage = critical, digitalSignature, keyEncipherment, keyAgreementextendedKeyUsage = serverAuth, clientAuth
basicConstraints = critical -
Generate the CSR private key:
# openssl genpkey -algorithm RSA -out mtls_client_private_key.pem \ -pkeyopt rsa_keygen_bits:4096
The certification authority (CA) private keys are extremely sensitive items in terms of security. You must follow the ANSSI recommendations concerning their life cycles.
-
Generate the CSR:
# openssl req -new -key mtls_client_private_key.pem \-out mtls_client.csr -config mtls_client_csr.cnf -extensions req_ext
-
Check the CSR:
# openssl req -text -noout -in mtls_client.csr
-
POST the mtls_client.csr content to the URI/{tenantId}/.well-known/est/simpleenroll endpoint with the following headers:
-
Content-Type must be application/pkcs10,
-
Content-Transfer-Encoding must be base64.
The response, Content-Type : application/pkcs7-mime, is a base64 string in PEM style (line breaks every 76 characters), containing the issued certificate in PKCS#7.
-
-
If the PKCS#7 content was saved in a mtls_client_certificate.p7 file, extract the issued certificate using these OpenSSL commands:
# openssl base64 -d -in mtls_client_certificate.p7 | \openssl pkcs7 -inform DER -outform PEM -print_certs \-out mtls_client_certificate.pem
-
Use both mtls_client_private_key.pem and mtls_client_certificate.pem in the HTTPS agent of your service or with CURL to activate mTLS authentication.