I need to create a python script to open the prompt, open openssl and launch the command to generate the public and private keys.
follows the command I use to generate the keys manually by opening the windows command prompt:
openssl
> req -x509 -nodes -days 100000 -newkey rsa:2048 -keyout privatekey.pem -out publickey.pem -subj '/'
I'm looking for a way to automate this process using the "subprocess" package of python to manipulate the prompt, but when I use the subprocess and play this command it gives an error:
Script Python:
import os
import base64
def main():
# s_client -connect google.com:443
subprocess.run("openssl req -config files_input/openssl.cnf -x509 -nodes -days 100000 -newkey rsa:2048 -keyout testeprivatekey.pem -out testepublickey.pem -subj '/'")
if __name__ == '__main__':
main()
Erro to execute script python:
Generating a RSA private key
.........................................................................+++++
..+++++
writing new private key to 'privatekey.pem'
-----
name is expected to be in the format /type0=value0/type1=value1/type2=... where characters may be escaped by \. This name is not in that format: ''/''
problems making Certificate Request
Please, i need help!