PKI // Playing with OpenSSL


quick shot RSA w/o being prompted for any value

    cd /etc/ssl/
    #cd /etc/openssl/

openssl req -x509 -newkey rsa:2048 -nodes \
    -subj /CN=* \
    -keyout /etc/ssl/self.key \
    -out /etc/ssl/self.crt
    # -days 365
    # -days 9999
    # -sha256
chmod 400 /etc/ssl/*.key
chmod 444 /etc/ssl/*.crt

instead of tweaking openssl.cnf you may also define more from the command line

-subj "/C=RU/L=Innopolis/O=Innopolis University/OU=SNE/CN=*.example.local/emailAddress=YOUR-EMAIL"

ECDSA with a 256-bit curve

openssl ecparam -name prime256v1
openssl req -x509 -days 365 -nodes \
    -newkey ec:<(openssl ecparam -name prime256v1) \
    -keyout prime256v1.key \
    -out prime256v1.crt

ECDSA with a 384-bit curve

openssl ecparam -name secp384r1
openssl req -x509 -days 3650 -nodes \
    -newkey ec:<(openssl ecparam -name secp384r1) \
    -keyout secp384r1.key \
    -out secp384r1.crt

Note - you can also use stdout instead of -out and stdin instead of -in

Note - -nodes to avoid encrypting the private key hence no passphrase

and review the newly created dummy certificate

ls -lF *.crt *.key
openssl x509 -in self.crt -text -noout -fingerprint
openssl x509 -in self.crt -text -noout | less


the important keyword here is -new and w/o -x509


one shot

openssl req -new -newkey rsa:2048 -nodes \
    -keyout $domain.key \
    -out $domain.csr

–vs– privkey then csr

openssl genrsa -out $domain.key 2048

    openssl req -new -nodes \
    -key $domain.key \
    -out $domain.csr


openssl ecparam -list_curves | grep secp384r1
openssl ecparam -name secp384r1 -genkey -noout -out client-or-domain.key
chmod 400 client-or-domain.key
openssl req -new -sha256 -key client-or-domain.key -out client-or-domain.csr
chmod 444 client-or-domain.csr

ready to go

and check

    ls -lF *.csr
openssl req -noout -text -verify < client-or-domain.csr


in case you need a container for your keys

openssl pkcs12 -export -inkey self.key -in self.crt -out self.p12
openssl pkcs12 -export -inkey prime256v1.key -in prime256v1.crt -out prime256v1.p12
openssl pkcs12 -export -inkey secp384r1.key -in secp384r1.crt -out secp384r1.p12

Ubuntu’s Sake-oil

You already have a pair on Ubuntu

ls -lF /etc/ssl/certs/ssl-cert-snakeoil.pem /etc/ssl/private/ssl-cert-snakeoil.key

but in case you need to re-generate those

make-ssl-cert generate-default-snakeoil --force-overwrite

#openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
#   -keyout /etc/ssl/private/ssl-cert-snakeoil.key \
#   -out /etc/ssl/certs/ssl-cert-snakeoil.pem

NetBSD fix

On NetBSD you need to fix the config first

cp -i /usr/share/examples/openssl/openssl.cnf /etc/openssl/
cp -i /usr/share/examples/openssl/openssl.cnf /etc/openssl/openssl.cnf.dist
vi /etc/openssl/openssl.cnf

#default_md             = sha2

Concat an official certificate chain

Once you sent your CSR to your SSL provider, it will respond you with the PEM certificate, possibly as .crt. You will also need their root CA and intermediate certificates – if those aren’t delivered, you might find it on their website. Eventually concatenate those two

cd /etc/httpd/ssl/
cat intermediatecert rootcert > issuer-concat-cert.crt
chmod 400 issuer-concat-cert.crt

Comparing trust stores


Assessing SSL end-points

see sslhappy-tools


How To Create an SSL Certificate on Nginx for Ubuntu 14.04

OpenSSL tips and tricks

What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

Command Line Utilities


A note about SSL/TLS trusted certificate stores, and platforms (OpenSSL and GnuTLS)

mk-ca-bundle the man page


How do I re-issue OpenSSL snakeoil cert?

How To Create a Self-Signed SSL Certificate for Nginx in Ubuntu 18.04

Creating a Self-Signed SSL Certificate on Ubuntu



How can I use OpenSSL with an external source of randomness?

Good entropy source for generating openssl keys

Random Numbers

How to speed up OpenSSL/GnuPG Entropy For Random Number Generation On Linux

Using engines for random number generation


Is it possible to generate RSA key without pass phrase?

Why openssl insist on requiring a passphrase on genrsa command?

Creating a .pem File for SSL Certificate Installations

concat certs

Does .pem file contains both private and public keys?

How to combine various certificates into single .pem ==> leaf comes first


req: Unrecognized flag sha2

How to make OpenSSL with SHA256 instead of sha1?

Generating an SHA256 SSL CSR on CentOS/RHEL using genkey



Create a self-signed ECC certificate

Generate self-signed certificate and key in one line

Generate Self-Signed SSL Certificate without prompt

Frequently used OpenSSL Commands

self-signed w/ san

Create an OpenSSL self-signed SAN cert in a single command


2 Testing TLS with OpenSSL

How to Verify A Connection is Secure Using OpenSSL ==> crlf

dst vs isrg

Root Certificates

Certificate Compatibility

Standing on Our Own Two Feet [Updated]

Valid-isrgrootx1 testing site working on devices it shouldn’t?

Old Let’s Encrypt Root Certificate Expiration and OpenSSL 1.0.2

RHEL/CentOS 7 Fix for Let’s Encrypt Change

Centos7 don’t trust certificate issued by lets encrypt

Let’s Encrypt Transitioning to ISRG’s Root

Copyright © 2024 Pierre-Philipp Braun