From 3f648525fbf544104f3de254d4b5e81e12e1a077 Mon Sep 17 00:00:00 2001 From: kares Date: Wed, 16 Oct 2024 12:35:34 +0200 Subject: [PATCH] [refactor] simplify - extra checks not needed --- src/main/java/org/jruby/ext/openssl/PKeyEC.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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()); } } }