CertUtils: export private key to pem format correctly (#2875)

This makes openssl rsa -in <file> -check pass, due to "RSA" string the
validate of private key (pem file) by openssl fails. Also removes
a commented import.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2018-10-05 04:45:47 +05:30 committed by GitHub
parent 8c0b9d6202
commit 0c943ab1f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -75,8 +75,6 @@ import org.joda.time.DateTimeZone;
import com.google.common.base.Strings;
//import org.bouncycastle.x509.extension.SubjectKeyIdentifierStructure;
public class CertUtils {
private static final Logger LOG = Logger.getLogger(CertUtils.class);
@ -132,7 +130,7 @@ public class CertUtils {
}
public static String privateKeyToPem(final PrivateKey key) throws IOException {
final PemObject pemObject = new PemObject("RSA PRIVATE KEY", key.getEncoded());
final PemObject pemObject = new PemObject("PRIVATE KEY", key.getEncoded());
final StringWriter sw = new StringWriter();
try (final PemWriter pw = new PemWriter(sw)) {
pw.writeObject(pemObject);