I am trying to generate public key from private key generated using python subprocess.run() where I store the private key in a variable, not in a file. I want to use the same buffer variable as input to openssl rsa command as input which it can use to generate the public key. I am not sure how to pass this buffer in python code-
#generating private key and keeping it in a variable
filedata = subprocess.run(['openssl', 'genrsa', '4096'], check=True, stdout=subprocess.PIPE, universal_newlines=True).stdout
Now using that filedata in openssl rsa command, how to pass this in python command in os.system() or subprocess.run()
os.system("openssl rsa -in private.key -pubout > public.key")
Is it possible to pass private.key data from the variable which holds the data to openssl rsa? Here I am avoiding to store the private key contents in a file. That is why I am using the filedata variable.
thanks for your reply.