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

后端 未结 8 963
有刺的猬
有刺的猬 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:35

    You shouldn't have to make any changes to the certificate. Are you sure you are running the right import command?

    The following works for me:

    keytool -import -alias joe -file mycert.cer -keystore mycerts -storepass changeit
    

    where mycert.cer contains:

    -----BEGIN CERTIFICATE-----
    MIIFUTCCBDmgAwIBAgIHK4FgDiVqczANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
    BhMCVVMxEDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAY
    ...
    RLJKd+SjxhLMD2pznKxC/Ztkkcoxaw9u0zVPOPrUtsE/X68Vmv6AEHJ+lWnUaWlf
    zLpfMEvelFPYH4NT9mV5wuQ1Pgurf/ydBhPizc0uOCvd6UddJS5rPfVWnuFkgQOk
    WmD+yvuojwsL38LPbtrC8SZgPKT3grnLwKu18nm3UN2isuciKPF2spNEFnmCUWDc
    MMicbud3twMSO6Zbm3lx6CToNFzP
    -----END CERTIFICATE-----
    

提交回复
热议问题