Skip to content

Commit ad67878

Browse files
committed
[fix] resolving EC key from X509::Request.new(pem)
1 parent 7bafbb5 commit ad67878

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/org/jruby/ext/openssl/X509Request.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
111111
throw newRequestError(runtime, "invalid certificate request data", e);
112112
}
113113

114-
final String algorithm; final byte[] encoded;
114+
final String algorithm;
115+
final byte[] encoded;
115116
try {
116117
final PublicKey pkey = request.generatePublicKey();
117118
algorithm = pkey.getAlgorithm();
118119
encoded = pkey.getEncoded();
119120
}
120-
catch (IOException e) { throw newRequestError(runtime, e); }
121-
catch (GeneralSecurityException e) { throw newRequestError(runtime, e); }
121+
catch (IOException|GeneralSecurityException e) {
122+
throw newRequestError(runtime, e);
123+
}
122124

123125
final RubyString enc = RubyString.newString(runtime, encoded);
124126
if ( "RSA".equalsIgnoreCase(algorithm) ) {
@@ -127,6 +129,9 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
127129
else if ( "DSA".equalsIgnoreCase(algorithm) ) {
128130
this.public_key = newPKeyImplInstance(context, "DSA", enc);
129131
}
132+
else if ( "EC".equalsIgnoreCase(algorithm) ) {
133+
this.public_key = newPKeyImplInstance(context, "EC", enc);
134+
}
130135
else {
131136
throw runtime.newNotImplementedError("public key algorithm: " + algorithm);
132137
}

0 commit comments

Comments
 (0)