Skip to content

Commit

Permalink
[fix] avoid PKey::EC.new failing with specific DER (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed Oct 30, 2024
1 parent 7bde518 commit 1dce0ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/jruby/ext/openssl/PKeyEC.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ public static RubyArray builtin_curves(ThreadContext context, IRubyObject self)
return curves;
}

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

Expand Down

0 comments on commit 1dce0ed

Please sign in to comment.