![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e225. Importing a Certificate from a FileSee also e224 Exporting a Certificate to a File.// This method reads a certificate to a file. The certificate can be either // binary or base64 encoded. public static java.security.cert.Certificate importCertificate(File file) { try { FileInputStream is = new FileInputStream(file); CertificateFactory cf = CertificateFactory.getInstance("X.509"); java.security.cert.Certificate cert = cf.generateCertificate(is); return cert; } catch (CertificateException e) { } catch (IOException e) { } return null; }A certificate can be imported into a keystore using keytool :
> keytool -storepass my-keystore-password -alias myalias -import -file infilename.cer
e224. Exporting a Certificate to a File e226. Listing All Available Certificate Formats e227. Getting the Subject and Issuer Distinguished Names of an X509 Certificate
© 2002 Addison-Wesley. |