Skip to content

Instantly share code, notes, and snippets.

@mehrdad-shokri
Last active April 8, 2018 02:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mehrdad-shokri/290eaf29e0dea5808e910b8742f366ba to your computer and use it in GitHub Desktop.
Save mehrdad-shokri/290eaf29e0dea5808e910b8742f366ba to your computer and use it in GitHub Desktop.
Install self signed certificates in ubuntu
openssl genrsa -out key.pem 2048
#OR if you want encrypted ca
openssl genrsa -de3 -out key.pem 2048
openssl req -new -key key.pem -out cert.csr -sha256 -config openssl.cnf
openssl x509 -req \
-days 1024 \
-in cert.csr \
-signkey key.pem \
-out cert.crt \
-extensions req_ext \
-extfile openssl.cnf
openssl x509 -in cert.crt -out cert.pem -outform PEM
# Chrome won't allow to import self signed certificates which contain subjectNames directly. So we should do as certtool.
## Install ``certutil``
sudo apt-get install libnss3-tools
## The following command will add the certificate (where YOUR_FILE is your exported file):
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n cert.pem -i cert.pem
#where cert.pem is the name of your certificate. To see a list of all your certificates and their names use this command:
## To see if it actually worked, you can list all of your certificates with this command:
certutil -d sql:$HOME/.pki/nssdb -L
## Removing A Certificate
certutil -D -d sql:$HOME/.pki/nssdb -n cert.pem
hotel stop
kill node
$kill chrome
openssl req -in cert.csr -noout -text
openssl x509 -in cert.pem -noout -text
openssl x509 -in cert.crt -noout -text
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
req_extensions = req_ext
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = IR
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Tehran
localityName = Locality Name (eg, city)
localityName_default = Tehran
organizationName = Organization Name (eg, company)
organizationName_default = Mehrdad
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_max = 64
commonName_default = dev.mehi
organizationalUnitName = Orgazization Unit
organizationalUnitName_default = Dev
[ req_ext ]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = dev.mehi
DNS.2 = www.dev.mehi
DNS.3 = *.dev.mehi
DNS.4 = www.*.dev.mehi
DNS.5 = localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment