Python OpenSSL generating public and private key pair

opensslprivatepublicpython

I am having problem finding a command that would generate a public and private key pair using OpenSSL. Could someone show me some example code of this in action.

Thank you

Best Answer

Using the pyOpenSSL bindings:

OpenSSL.crypto.PKey().generate_key(type, bits)

Generate a public/private key pair of the type type (one of TYPE_RSA and TYPE_DSA) with the size bits.

Docs