How to import a .cer certificate into a java keystore?

后端 未结 8 850
有刺的猬
有刺的猬 2020-11-22 15:38

During the development of a Java webservice client I ran into a problem. Authentication for the webservice is using a client certificate, a username and a password. The clie

8条回答
  •  无人及你
    2020-11-22 16:32

    Importing .cer certificate file downloaded from browser (open the url and dig for details) into cacerts keystore in java_home\jre\lib\security worked for me, as opposed to attemps to generate and use my own keystore.

    1. Go to your java_home\jre\lib\security
    2. (Windows) Open admin command line there using cmd and CTRL+SHIFT+ENTER
    3. Run keytool to import certificate:
      • (Replace yourAliasName and path\to\certificate.cer respectively)

     ..\..\bin\keytool -import -trustcacerts -keystore cacerts -storepass changeit -noprompt -alias yourAliasName -file path\to\certificate.cer
    

    This way you don't have to specify any additional JVM options and the certificate should be recognized by the JRE.

提交回复
热议问题