Programmatically Import CA trust cert into existing keystore file without using keytool

前端 未结 2 573
盖世英雄少女心
盖世英雄少女心 2020-11-28 06:41

I would like to create a JAVA program that import the .cer CA into the existing keystore file. So that end-user can insert the CA cert more convenience(without using CMD and

2条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 07:28

    Download certs from links and store into specific path.. then load that file into trustStore during runtime using below code.. i hope this exaple will help you..

    KeyStore keyStore = KeyStore.getInstance("JKS");
    String fileName = "D:\\certs_path\\cacerts"; // cerrtification file path
    System.setProperty("javax.net.ssl.trustStore", fileName);
    

提交回复
热议问题