Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from subprocess import call
- print("conversion available: ")
- print("1: PEM to DER")
- print("2: PEM to P7B")
- print("3: PEM to PFX")
- print("4: pfx to PEM")
- print("5: pfx to P7B")
- print("6: pfx to DER")
- print("7: DER to PEM")
- print("8: DER to pfx")
- print("9: DER to P7B")
- print("10: P7B to PEM")
- print("11: P7B to pfx")
- print("12: P7B to DER")
- choise = input("conversion number: ")
- if choise == 1:
- print("PEM -> DER")
- print("==========")
- nome = input('Inserisci il nome del file .pem: ')
- cmd = "openssl x509 -outform der -in "+nome+".pem -out certificate.der"
- if choise == 2:
- print("PEM to P7B")
- print("==========")
- nome = input('Inserisci il nome del file .pem: ')
- cmd = "openssl crl2pkcs7 -nocrl -certfile "+nome+".pem -out certificatename.p7b -certfile CACert.cer"
- if choise == 3:
- print("PEM -> PFX")
- print("==========")
- nome = input('Inserisci il nome del file .PEM: ')
- cmd = "openssl pkcs12 -export -in cert.cer -inkey "+nome+".pem -out certificate.pfx -certfile CA.cer"
- if choise == 4:
- print("pfx to PEM")
- print("==========")
- nome = input('Inserisci il nome del file .pfx: ')
- cmd = "openssl pkcs12 -in "+nome+".pfx -out certificatename.pem"
- if choise == 5:
- print("pfx to P7B")
- print("==========")
- nome = input('Inserisci il nome del file .pfx: ')
- cmd = "openssl pkcs12 -in "+nome+".pfx -out certificatename.pem"
- decrypted = call([cmd], shell=True)
- cmd = "openssl crl2pkcs7 -nocrl -certfile certificatename.pem -out certificatename.p7b -certfile CACert.cer"
- if choise == 6:
- print("pfx to DER")
- print("==========")
- nome = input('Inserisci il nome del file .pfx: ')
- cmd = "openssl pkcs12 -in "+nome+".pfx -nocerts -nodes -out certificatename.pem"
- decrypted = call([cmd], shell=True)
- cmd = "openssl x509 -outform der -in certificatename.pem -out certificate.der"
- if choise == 7:
- print("DER -> PEM")
- print("==========")
- nome = input('Inserisci il nome del file .der: ')
- cmd = "openssl x509 -inform der -in "+nome+".der -out certificatename.pem"
- if choise == 8:
- print("DER -> pfx")
- print("==========")
- nome = input('Inserisci il nome del file .der: ')
- cmd = "openssl x509 -inform der -in "+nome+".der -out certificatename.pem"
- decrypted = call([cmd], shell=True)
- cmd = "openssl pkcs12 -export -in cert.cer -inkey certificatename.pem -out certificate.pfx -certfile CA.cer"
- if choise == 9:
- print("DER -> P7B")
- print("==========")
- nome = input('Inserisci il nome del file .der: ')
- cmd = "openssl x509 -inform der -in "+nome+".der -out certificatename.pem"
- decrypted = call([cmd], shell=True)
- cmd = "openssl crl2pkcs7 -nocrl -certfile certificatename.pem -out certificatename.p7b -certfile CACert.cer"
- if choise == 10:
- print("P7B -> PEM")
- print("==========")
- nome = input('Inserisci il nome del file .p7b: ')
- cmd = "openssl pkcs7 -print_certs -in "+nome+".p7b -out certificate.pem"
- if choise == 11:
- print("P7B -> pfx")
- print("==========")
- nome = input('Inserisci il nome del file .p7b: ')
- cmd = "openssl pkcs7 -print_certs -in "+nome+".p7b -out certificate.pem"
- decrypted = call([cmd], shell=True)
- cmd = "openssl pkcs12 -export -in certificate.pem -inkey privateKey.key -out certificate.pfx -certfile CACert.cer"
- if choise == 12:
- print("P7B -> DER")
- print("==========")
- nome = input('Inserisci il nome del file .p7b: ')
- cmd = "openssl pkcs7 -print_certs -in "+nome+".p7b -out certificate.pem"
- decrypted = call([cmd], shell=True)
- cmd = "openssl x509 -outform der -in certificate.pem -out certificate.der"
- decrypted = call([cmd], shell= True)
- print(decrypted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement