openssl genrsa -out ca.key 2048
openssl rsa -in private.key -pubout -out public.key
openssl req -newkey rsa:2048 -nodes -x509 -days 365 -out ca.crt -keyout ca.key
-newkey algo:bit = generate a new private key
-nodes = Don't encrypt the output key
-x509 = output should be of x509 structure
-days DAY = validity of the certificate
-out = output file of certificate
-keyout = output file of the key
-subj "/CN=mongo/O=kubedb" # Prompt will open, if not given.
openssl req -new -key server.key -days 365 -out server.csr
-new = A new request
openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr
openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=*.example.com"
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365 -sha256
-req = input is a certificate request
-in = input csr file -CAcreateserial = create serial if doesn't exist
echo "subjectAltName=DNS:some.host" > altsubj.ext
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365 -sha256 -extfile altsubj.ext
openssl x509 -req -in example.csr -signkey example.key -out example.crt -days 3650 -sha256 -extfile altsubj.ext
-signkey = to sign self cert
NB: According to RFC 6125, If SAN is present then CN should not be checked.