How to export private key and certificate from pfx file to jks file?

Prepare:
  1. Given the directory mycert.pfx is ‘D:\Mycert.pfx’
  2. you have installed ‘Openssl’
  3. java bin has been set in environment variables path, so that you can use ‘Keytool’
  4. download jetty-6.1.1.jar
 
Steps to export key and certificate:

 0.   use keytool to check the pfx file has private key and certificate info  
 
1.      export private key from pfx to jks file:
open command   line, input command as following
 
 
java -classpath lib/jetty-6.1.1.jar rg.mortbay.jetty.security.PKCS12Import
c:\MyCert.pfx  c:\Mykey.jks
Enter input keystore passphrase: ******     (password of pfx)
Enter output keystore passphrase: ******   (password of pfx)
 
 
2.      export certificate from pfx file to jks file:
1)      Open openssl window, input command as following
 
2)                         
3)                        OpenSSL> pxcs12 -in MyCert.pfx -out Mycert.pem -nodes
4)                        OpenSSL> x509 -in Mycert.pem   -inform PEM -out Mycert.der
5)                                           -outform DER
   2) Open another command line
 
 
Input keytool -import -keystore Mycert.jks -storepass changeit -file Mycert.der
 
 
Mycert.jks will contain the certificate info of Mycert.pfx
Mykey.jks will contain the private key of Mycert.pfx
 

本文出自 “遇见思考中的你” 博客,转载请与作者联系!

你可能感兴趣的:(职场,休闲)