Java examples for Security:Certificate
Importing a Certificate from a File
import java.io.File; import java.io.FileInputStream; import java.security.cert.CertificateFactory; public class Main { public static java.security.cert.Certificate importCertificate(File file) { try {//from www . j a va2 s. com FileInputStream is = new FileInputStream(file); CertificateFactory cf = CertificateFactory.getInstance("X.509"); java.security.cert.Certificate cert = cf.generateCertificate(is); return cert; } catch (Exception e) { } return null; } }
> keytool -storepass my-keystore-password -alias myalias -import -file infilename.cer