Self-Signed Certificate
- A CA will only sign your certificate if you control a domain name
- Buy a domain name and prove to the CA that you control it
- Cannot get a signed cert for "localhost"
- You can generate our own self-signed certificates
- For development/educational purposes only!
- When you deploy an app for real users, do not use a self- signed cert!
- These certs cannot be verified and are therefor vulnerable to man-in-the-middle attacks
OpenSSL
- OpenSSL is a very common SSL/TLS library
- Written in C
- Wrappers exist for many languages
- Can be used for many encryption needs
- Generating keys
- Signing certs
- Validating certs
- Can use OpenSSL in the command line to generate self-signed certificates
Self-Signed Certificate
openssl req -x509 -newkey rsa:4096 -keyout private.key -out cert.pem -days 365 -sha256 -nodes
- This command has many options
- req
- Request a signed certificate
- -x509
- Use the x509 standard format for the certificate
- -newkey rsa:4096
- Generate a new key for this cert using the RSA algorithm and a 4k key size
Self-Signed Certificate
openssl req -x509 -newkey rsa:4096 -keyout private.key -out cert.pem -days 365 -sha256 -nodes
- -keyout private.key
- Save the private key in a file named "private.key"
- -out cert.pem
- Save the public certificate in a file named "cert.pem"
- -days 365
- This certificate will expire in 1 year
- -nodes
- Do not require a password to use the private key
Self-Signed Certificate
openssl req -x509 -newkey rsa:4096 -keyout private.key -out cert.pem -days 365 -sha256 -nodes
- Assuming openSSL is installed you can run commands in the command line
- This command will generate a self-signed certificate and private key
Self-Signed Certificate
openssl req -x509 -newkey rsa:4096 -keyout private.key -out cert.pem -days 365 -sha256 -nodes -subj "/C=US"
- If you run the command on the previous slides, you'll be asked a lot of questions
- For most, you can hit enter and leave them blank
- You must enter your country code though (eg. "us")
- Or add -subj "/C=US"
- This lets you set your answers to all the questions
- Required to set country code, and you can leave the rest blank
- Allows you run this command in a script
Generating a Key Pair
openssl genrsa -out auth_private.key 4096 openssl rsa -in auth_private.key -pubout -out auth_public.key
- If you only want a public/private key pair
- You can run these 2 commands
- Helpful for your auth server since you don't need a certificate