When I try to generate a private key, I get the following; ‘openssl:Error: ‘genpkey’ is an invalid command.’ What am I doing wrong?
You probably have an old version of
openssl — MacOS comes with an old version by default, which is … annoying.
genpkey is a replacement for the old key-generation utilities. If you use Homebrew (https://brew.sh), you can install openssl and run
genpkey using the new version.
brew install openssl
This will install by default in
/usr/local/opt/openssl/bin (you’ll see a message describing why). Then you can run
genpkey as in the example:
/usr/local/opt/openssl/bin/openssl genpkey [options]
If you don’t feel like updating your version this worked for me:
openssl genrsa -des3 -out private.pem 2048
openssl rsa -pubout -in private.pem -out public.pem