Certified Security - Specialty

Sign Up Free or Log In to participate!

openssl:Error: ‘genpkey’ is an invalid command.

When I try to generate a private key, I get the following; ‘openssl:Error: ‘genpkey’ is an invalid command.’  What am I doing wrong?

2 Answers

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

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?