I know I can generate an OpenVPN static key by 'openvpn --genkey --secret myfile.key'. In python, I am currently using a shell call to generate a key, open the 'myfile.key' and read it back in. It would be much cleaner if I could do it without the shell call.
Does anyone know what type of key is generated with the --genkey command, or a way to generate the key directly in Python?
Unfortunately, OpenVPN doesn't currently provide Python APIs. However, one way to (slightly) clean up your script would be to have it generate the key directly to
stdout
, and then use thestdout
returned byPopen
.I.e.,
As far as I know, even though the keys are generated using the TLS PRF function, there's no "other" way to generate the keys.