I got private key which I would like to export to .pem format Problem is that, when I call privateKey.getEncoded() I get null. But I can get all info like exponent, modulus and so one (all from interface RSAPrivateKey). privateKey is org.mozilla.jss.pkcs11.PK11RSAPrivateKey Object.
public String exportPrivateKey(PrivateKey privateKey) throws Throwable {
byte[] encoded = privateKey.getEncoded();//this is null:<
String body = DatatypeConverter.printBase64Binary(encoded);
return RSA_PRIVATE_HEADER + body + RSA_PRIVATE_FOOTER;
}
How to export that key to pem file?