public static void updateWithCaPem ( KeyStore pTrustStore , File pCaCert ) throws IOException , CertificateException , KeyStoreException , NoSuchAlgorithmException { InputStream is = new FileInputStream ( pCaCert ) ; try { CertificateFactory certFactory = CertificateFactory . getInstance ( "X509" ) ; X509Certificate cert = ( X509Certificate ) certFactory . generateCertificate ( is ) ; String alias = cert . getSubjectX500Principal ( ) . getName ( ) ; pTrustStore . setCertificateEntry ( alias , cert ) ; } finally { is . close ( ) ; } }
Update a keystore with a CA certificate