Export Certificate and Private Key From Key Manager
To export a certificate and its private key from the Key Manager:
Create an
NAESession
object (session).Create an
NAECertificate
object (mycert).Call the
export()
method of theNAECertificate
object and store the data in a byte array. Theexport()
method exports the certificate in one of the following formats:PEM-PKCS#1: Includes the certificate and the RSA private key in PKCS#1 format.
PEM-PKCS#8: Includes the certificate and the RSA private key in PKCS#8 format.
PEM-PKCS#12: This format is base64-encoded. You must include the password.
Use a
FileOutputStream
(fos) to put the byte array into a file on the client (outputCert.crt)Close the stream.
Code sample
NAESession session = NAESession.getSession("userOne", "1234".toCharArray());
NAECertificate mycert = new NAECertificate ("CertOne", session);
byte[] exportData = mycert.export("PEM-PKCS#1", null);
FileOutputStream fos = new FileOutputStream("/outputCert.crt");
fos.write(exportData);
fos.close();