How to import an existing X.509 certificate and private key in Java keystore to use in SSL?

前端 未结 15 884
说谎
说谎 2020-11-22 08:05

I have this in an ActiveMQ config:


        

        
15条回答
  •  逝去的感伤
    2020-11-22 08:17

    Keytool in Java 6 does have this capability: Importing private keys into a Java keystore using keytool

    Here are the basic details from that post.

    1. Convert the existing cert to a PKCS12 using OpenSSL. A password is required when asked or the 2nd step will complain.

      openssl pkcs12 -export -in [my_certificate.crt] -inkey [my_key.key] -out [keystore.p12] -name [new_alias] -CAfile [my_ca_bundle.crt] -caname root
      
    2. Convert the PKCS12 to a Java Keystore File.

      keytool -importkeystore -deststorepass [new_keystore_pass] -destkeypass [new_key_pass] -destkeystore [keystore.jks] -srckeystore [keystore.p12] -srcstoretype PKCS12 -srcstorepass [pass_used_in_p12_keystore] -alias [alias_used_in_p12_keystore]
      

提交回复
热议问题