-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenssl.py
More file actions
30 lines (24 loc) · 780 Bytes
/
openssl.py
File metadata and controls
30 lines (24 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python
#
# login certificate manager
#
#
# To convert a certificate from DER to PEM:
# x509 -in cert.der -inform DER -out cert.pem -outform PEM
# To convert a key from DER to PEM:
# rsa -in privatekey.der -inform DER -out privatekey.pem -outform PEM
# To convert a key from NET to PEM:
# rsa -in privatekey.net -inform NET -out privatekey.pem -outform PEM
#
# openssl pkcs12 -export -in cert.pem -inkey privatekey.pem -out logincert.p12
#
from subprocess import Popen
from shlex import split
def generateLoginCert(cert, key):
if isDERcert(cert):
cert = DER2PEMcert(cert)
if isDERkey(key):
key = DER2PEMkey(key)
elif isNETkey(key):
key = NET2PEMkey(key)
Popen(split('openssl pkcs12 -export -in cert.pem -inkey privatekey.pem -out logincert.p12')).wait()