Advertisement
AlessandroG

Untitled

Dec 6th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. from subprocess import call
  2. print("conversion available: ")
  3. print("1: PEM to DER")
  4. print("2: PEM to P7B")
  5. print("3: PEM to PFX")
  6.  
  7. print("4: pfx to PEM")
  8. print("5: pfx to P7B")
  9. print("6: pfx to DER")
  10.  
  11. print("7: DER to PEM")
  12. print("8: DER to pfx")
  13. print("9: DER to P7B")
  14.  
  15. print("10: P7B to PEM")
  16. print("11: P7B to pfx")
  17. print("12: P7B to DER")
  18.  
  19. choise = input("conversion number: ")
  20.  
  21. if choise == 1:
  22. print("PEM -> DER")
  23. print("==========")
  24. nome = input('Inserisci il nome del file .pem: ')
  25. cmd = "openssl x509 -outform der -in "+nome+".pem -out certificate.der"
  26. if choise == 2:
  27. print("PEM to P7B")
  28. print("==========")
  29. nome = input('Inserisci il nome del file .pem: ')
  30. cmd = "openssl crl2pkcs7 -nocrl -certfile "+nome+".pem -out certificatename.p7b -certfile CACert.cer"
  31. if choise == 3:
  32. print("PEM -> PFX")
  33. print("==========")
  34. nome = input('Inserisci il nome del file .PEM: ')
  35. cmd = "openssl pkcs12 -export -in cert.cer -inkey "+nome+".pem -out certificate.pfx -certfile CA.cer"
  36.  
  37. if choise == 4:
  38. print("pfx to PEM")
  39. print("==========")
  40. nome = input('Inserisci il nome del file .pfx: ')
  41. cmd = "openssl pkcs12 -in "+nome+".pfx -out certificatename.pem"
  42. if choise == 5:
  43. print("pfx to P7B")
  44. print("==========")
  45. nome = input('Inserisci il nome del file .pfx: ')
  46. cmd = "openssl pkcs12 -in "+nome+".pfx -out certificatename.pem"
  47. decrypted = call([cmd], shell=True)
  48. cmd = "openssl crl2pkcs7 -nocrl -certfile certificatename.pem -out certificatename.p7b -certfile CACert.cer"
  49. if choise == 6:
  50. print("pfx to DER")
  51. print("==========")
  52. nome = input('Inserisci il nome del file .pfx: ')
  53. cmd = "openssl pkcs12 -in "+nome+".pfx -nocerts -nodes -out certificatename.pem"
  54. decrypted = call([cmd], shell=True)
  55. cmd = "openssl x509 -outform der -in certificatename.pem -out certificate.der"
  56.  
  57. if choise == 7:
  58. print("DER -> PEM")
  59. print("==========")
  60. nome = input('Inserisci il nome del file .der: ')
  61. cmd = "openssl x509 -inform der -in "+nome+".der -out certificatename.pem"
  62. if choise == 8:
  63. print("DER -> pfx")
  64. print("==========")
  65. nome = input('Inserisci il nome del file .der: ')
  66. cmd = "openssl x509 -inform der -in "+nome+".der -out certificatename.pem"
  67. decrypted = call([cmd], shell=True)
  68. cmd = "openssl pkcs12 -export -in cert.cer -inkey certificatename.pem -out certificate.pfx -certfile CA.cer"
  69. if choise == 9:
  70. print("DER -> P7B")
  71. print("==========")
  72. nome = input('Inserisci il nome del file .der: ')
  73. cmd = "openssl x509 -inform der -in "+nome+".der -out certificatename.pem"
  74. decrypted = call([cmd], shell=True)
  75. cmd = "openssl crl2pkcs7 -nocrl -certfile certificatename.pem -out certificatename.p7b -certfile CACert.cer"
  76. if choise == 10:
  77. print("P7B -> PEM")
  78. print("==========")
  79. nome = input('Inserisci il nome del file .p7b: ')
  80. cmd = "openssl pkcs7 -print_certs -in "+nome+".p7b -out certificate.pem"
  81. if choise == 11:
  82. print("P7B -> pfx")
  83. print("==========")
  84. nome = input('Inserisci il nome del file .p7b: ')
  85. cmd = "openssl pkcs7 -print_certs -in "+nome+".p7b -out certificate.pem"
  86. decrypted = call([cmd], shell=True)
  87. cmd = "openssl pkcs12 -export -in certificate.pem -inkey privateKey.key -out certificate.pfx -certfile CACert.cer"
  88. if choise == 12:
  89. print("P7B -> DER")
  90. print("==========")
  91. nome = input('Inserisci il nome del file .p7b: ')
  92. cmd = "openssl pkcs7 -print_certs -in "+nome+".p7b -out certificate.pem"
  93. decrypted = call([cmd], shell=True)
  94. cmd = "openssl x509 -outform der -in certificate.pem -out certificate.der"
  95.  
  96. decrypted = call([cmd], shell= True)
  97. print(decrypted)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement