简体   繁体   中英

Request a URL that client certificate authentication

KeyStore ks = KeyStore.getInstance("PKCS12");
FileInputStream fis = new FileInputStream("/path/to/file.p12");
ks.load(fis, "password".toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, "password".toCharArray());
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(kmf.getKeyManagers(), null, null);

This code works fine. But is any possibility to use keystore.jks for that case? For example, I have imported file.p12 into keystore.jks using pkcs12import tool with some alias. Then I use System.setProperty("javax.net.ssl.keyStore" , "C:/Sun/SDK/jdk/jre/lib/security/keystore.jks"); and not write certificate path and password in java code and it take from that keystore.jks file

是的,可以使用jks密钥库来处理证书,可以在此处找到其示例

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM