Sometimes during development you may find yourself needing an SSL certificate and key to test with. I’ve had to do this so much I went ahead and added the below function to my ~/.bashrc
file.
createss ()
{
openssl req -x509 -nodes -newkey rsa:4096 \
-keyout ${1}.key -out ${1}.crt -days 365 \
-subj "/C=US/ST=Ohio/L=Elida/O=ShanerOPS/OU=OPS/CN=${1}"
}
Now, I can create certs on-the-fly without having to look it up in my notes. Here’s how it looks in practice.
$ createss demo.site.local
Generating a RSA private key
...........snip....
$ ls -l
-rw------- 1 shane shane 3272 Jul 20 20:47 demo.site.local.key
-rw-rw-r-- 1 shane shane 2033 Jul 20 20:47 demo.site.local.crt
Leave a Reply
You must be logged in to post a comment.