diff --git a/src/main/java/org/jruby/ext/openssl/PKeyEC.java b/src/main/java/org/jruby/ext/openssl/PKeyEC.java index 9c0330b8..0d1d2aa5 100644 --- a/src/main/java/org/jruby/ext/openssl/PKeyEC.java +++ b/src/main/java/org/jruby/ext/openssl/PKeyEC.java @@ -258,7 +258,7 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a final RubyString str = readInitArg(context, arg); final String strJava = str.toString(); - if (!strJava.isEmpty() && isCurveName(strJava)) { + if (isCurveName(strJava)) { this.curveName = strJava; return this; } @@ -349,8 +349,9 @@ else if ( key instanceof ECPublicKey ) { private void setCurveNameFromPublicKeyIfNeeded() { if (curveName == null && publicKey != null) { final String oid = getCurveNameObjectIdFromKey(getRuntime(), publicKey); - if (isCurveName(oid)) { - this.curveName = getCurveName(new ASN1ObjectIdentifier(oid)); + final Optional curveId = getCurveOID(oid); + if (curveId.isPresent()) { + this.curveName = getCurveName(curveId.get()); } } }