Java keytool easy way to add server cert from url/port

前端 未结 5 1952
攒了一身酷
攒了一身酷 2020-11-27 11:24

I have a server with a self signed certificate, but also requires client side cert authentication. I am having a rough time trying to get the raw CA server cert so I can imp

5条回答
  •  Happy的楠姐
    2020-11-27 11:44

    I use openssl, but if you prefer not to, or are on a system (particularly Windows) that doesn't have it, since java 7 in 2011 keytool can do the whole job:

     keytool -printcert -sslserver host[:port] -rfc >tempfile
     keytool -import [-noprompt] -alias nm -keystore file [-storepass pw] [-storetype ty] 

    Conversely, for java 9 up always, and for earlier versions in many cases, Java can use a PKCS12 file for a keystore instead of the traditional JKS file, and OpenSSL can create a PKCS12 without any assistance from keytool:

    openssl s_client -connect host:port 

提交回复
热议问题