Skip to content

Commit 8cbe28c

Browse files
committed
[fix] avoid PKey::EC.new failing with specific DER (#318)
1 parent 7bde518 commit 8cbe28c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ public static RubyArray builtin_curves(ThreadContext context, IRubyObject self)
171171
return curves;
172172
}
173173

174-
private static Optional<ASN1ObjectIdentifier> getCurveOID(final String curveName) {
174+
private static Optional<ASN1ObjectIdentifier> getCurveOID(String curveName) {
175+
if (curveName == null) return Optional.empty();
176+
// work-around getNamedCurveOid not being able to handle "... " (assuming spacePos + 1 is valid index)
177+
if (curveName.indexOf(' ') == curveName.length() - 1) return Optional.empty();
175178
return Optional.ofNullable(ECUtil.getNamedCurveOid(curveName));
176179
}
177180

0 commit comments

Comments
 (0)