Skip to content

Commit c48e3bd

Browse files
committed
obtain bit-length to avoid using deprecated constructor for (BC) ECPrivateKey
1 parent 3748750 commit c48e3bd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/org/jruby/ext/openssl/x509store/PEMInputOutput.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,8 @@ public static void writeECPrivateKey(Writer _out, ECPrivateKey obj, CipherSpec c
10381038
assert (obj != null);
10391039
final String PEM_STRING_EC = "EC PRIVATE KEY";
10401040
BufferedWriter out = makeBuffered(_out);
1041-
org.bouncycastle.asn1.sec.ECPrivateKey keyStruct = new org.bouncycastle.asn1.sec.ECPrivateKey(obj.getS());
1041+
final int bitLength = obj.getParams().getOrder().bitLength();
1042+
org.bouncycastle.asn1.sec.ECPrivateKey keyStruct = new org.bouncycastle.asn1.sec.ECPrivateKey(bitLength, obj.getS());
10421043
if (cipher != null && passwd != null) {
10431044
writePemEncrypted(out, PEM_STRING_EC, keyStruct.getEncoded(), cipher, passwd);
10441045
} else {

0 commit comments

Comments
 (0)