public static KeyStore createTrustStore ( final Reader certReader ) throws IOException , CertificateException , KeyStoreException , NoSuchAlgorithmException { try ( PEMParser pemParser = new PEMParser ( certReader ) ) { KeyStore trustStore = KeyStore . getInstance ( "JKS" ) ; trustStore . load ( null ) ; int index = 1 ; Object pemCert ; while ( ( pemCert = pemParser . readObject ( ) ) != null ) { Certificate caCertificate = new JcaX509CertificateConverter ( ) . setProvider ( BouncyCastleProvider . PROVIDER_NAME ) . getCertificate ( ( X509CertificateHolder ) pemCert ) ; trustStore . setCertificateEntry ( "ca-" + index , caCertificate ) ; index ++ ; } return trustStore ; } }
ca . pem from Reader