Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python OpenSSL generating public and private key pair

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

like image 555
DustBunny Avatar asked Sep 05 '25 03:09

DustBunny


1 Answers

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

like image 187
Katriel Avatar answered Sep 07 '25 15:09

Katriel