Skip to content

Instantly share code, notes, and snippets.

@artburkart
Last active July 15, 2019 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artburkart/a3fab7c43769a640ce35e2b15aa7823c to your computer and use it in GitHub Desktop.
Save artburkart/a3fab7c43769a640ce35e2b15aa7823c to your computer and use it in GitHub Desktop.
creating self-signed cert openssl

Create private key and signing request:

openssl genrsa 4096 > privatekey.pem
openssl req -new -key privatekey.pem -out csr.pem -config config.ini

The output looks like this:

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) [US]:
State or Province Name (full name) [New York]:
Locality Name (eg, city) [New York]:
Common Name (eg, DOMAIN name) []:example.com

Create self-signed certificate (this one will be valid for 1 day):

openssl x509 -req -days 1 -in csr.pem -signkey privatekey.pem -out server.crt

Inspect certificate:

openssl x509 -in server.crt -noout -text
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = US
countryName_min = 2
countryName_max = 2
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = New York
localityName = Locality Name (eg, city)
localityName_default = New York
commonName = Common Name (eg, YOUR name)
commonName_max = 64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment