Skip to content

Instantly share code, notes, and snippets.

@masihyeganeh
Last active December 28, 2015 16:09
Show Gist options
  • Save masihyeganeh/7527325 to your computer and use it in GitHub Desktop.
Save masihyeganeh/7527325 to your computer and use it in GitHub Desktop.
Generating Self-signed Certificate
mkdir keys # All keys will be generated in this folder
openssl genrsa -out keys/rootCA.key 2048 -des3 # CA Private key
openssl req -x509 -new -nodes -key keys/rootCA.key -days 1024 -out keys/rootCA.pem # CA self-signed certificate valid for 1024 days
# CA certificate should be imported to all devices that are using these self-signed certificates
openssl genrsa -out keys/server.key 2048 # Server private key
openssl req -new -key keys/server.key -out keys/server.csr # Server certificate signing request
openssl x509 -req -in keys/server.csr -CA keys/rootCA.pem -CAkey keys/rootCA.key -CAcreateserial -out keys/server.crt -days 1024 # Common Name should be server's host name or ip
openssl genrsa -out keys/client.key 2048 # Client private key
openssl req -new -key keys/client.key -out keys/client.csr # Client certificate signing request
openssl x509 -req -in keys/client.csr -CA keys/rootCA.pem -CAkey keys/rootCA.key -CAcreateserial -out keys/client.crt -days 1024 # Common Name should be client's host name or ip
@masihyeganeh
Copy link
Author

What this says anyway?

mkdir keys
openssl genrsa -out keys/rootCA.key 2048 -des3
openssl req -new -key keys/rootCA.key -out keys/rootCA.csr
openssl req -x509 -new -nodes -key keys/rootCA.key -days 1024 -out keys/rootCA.pem
openssl x509 -req -days 1024 -in keys/rootCA.csr -signkey keys/rootCA.key -out keys/rootCA.crt
openssl genrsa -out keys/device.key 2048
openssl req -new -key keys/device.key -out keys/device.csr
openssl x509 -req -in keys/device.csr -CA keys/rootCA.pem -CAkey keys/rootCA.key -CAcreateserial -out keys/device.crt -days 1024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment