Quick post: Generate a private / public key with openssl
PDFHere’s a way to quickly generate a private and public key:
1 2 3 | openssl genrsa -out dkim.pem 1024 openssl pkcs8 -topk8 -nocrypt -in dkim.pem -outform der -out dkim.der openssl rsa -in dkim.pem -pubout |
In Windows openssl needs a file in which to produce random data:
1 | set RANDFILE=C:\.rnd |
Running this results in the following CLI output:
And these two files will be generated:
- dkim.pem
- dkim.der
Since I work on a Windows pc, I have a very simple batch file that quickly generates one for me:
1 2 3 4 5 6 7 8 9 | @echo off set RANDFILE=D:\keys\.rnd openssl genrsa -out dkim.pem 1024 openssl pkcs8 -topk8 -nocrypt -in dkim.pem -outform der -out dkim.der openssl rsa -in dkim.pem -pubout pause |