Last active
December 22, 2015 20:39
-
-
Save acidprime/6527638 to your computer and use it in GitHub Desktop.
Python Example of Openssl commands needed for CSRs needed for windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python | |
openssl = '/usr/bin/openssl' | |
from subprocess import Popen, PIPE, STDOUT | |
def generateUserCSR(user_name,key,csr): | |
arguments = [ | |
openssl, | |
'req', | |
'-new', | |
'-batch', | |
'-newkey', | |
'rsa:2048', | |
'-nodes', | |
'-keyout', | |
'%s' % key, | |
'-out', | |
'%s' % csr, | |
'-subj', | |
'/CN=%s$' % user_name, | |
] | |
execute = Popen(arguments, stdout=PIPE) | |
out, err = execute.communicate() | |
def generateMachineCSR(machine_name,key,csr): | |
arguments = [ | |
openssl, | |
'req', | |
'-new', | |
'-batch', | |
'-newkey', | |
'rsa:2048', | |
'-nodes', | |
'-keyout', | |
'%s' % key, | |
'-out', | |
'%s' % csr, | |
'-subj', | |
'/CN=%s$' % machine_name , | |
] | |
execute = Popen(arguments, stdout=PIPE) | |
out, err = execute.communicate() | |
generateMachineCSR('/tmp/machine.key','/tmp/machine.csr') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment