{"record":{"id":"d07e9856f2a609c7","repo":"eclipse-vertx/vert.x","slug":"cannot-determine-ec-parameter-spec-for-curve-name","errorCode":null,"errorMessage":"Cannot determine EC parameter spec for curve name/OID","messagePattern":"Cannot determine EC parameter spec for curve name/OID","errorType":"exception","errorClass":"VertxException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/impl/pkcs1/PrivateKeyParser.java","lineNumber":77,"sourceCode":"        }\n        value <<= 7;\n        value |= (oid[index] & 0b01111111);\n        result.append(\".\").append(value);\n      } else {\n        result.append(\".\").append(bValue);\n      }\n    }\n    return result.toString();\n  }\n\n  private static ECParameterSpec getECParameterSpec(String curveName) throws VertxException {\n    try {\n      KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(\"EC\");\n      keyPairGenerator.initialize(new ECGenParameterSpec(curveName));\n      ECPublicKey publicKey = (ECPublicKey) keyPairGenerator.generateKeyPair().getPublic();\n      return publicKey.getParams();\n    } catch (GeneralSecurityException e) {\n      throw new VertxException(\"Cannot determine EC parameter spec for curve name/OID\", e);\n    }\n  }\n\n  /**\n   * Gets the algorithm used by a PKCS#8 encoded private key.\n   *\n   * @param encodedKey The encoded private key.\n   * @return The algorithm name, either <em>RSA</em> or <em>EC</em>, depending on\n   *         the algorithm identifier found in the encoded key.\n   * @throws VertxException if the key is not PKCS#8 encoded or uses an unsupported\n   *         algorithm.\n   */\n  public static String getPKCS8EncodedKeyAlgorithm(byte[] encodedKey) {\n\n    DerParser parser = new DerParser(encodedKey);\n    Asn1Object sequence = parser.read();\n    if (sequence.getType() != DerParser.SEQUENCE) {\n      throw new VertxException(\"Invalid PKCS8 encoding: not a sequence\");","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/impl/pkcs1/PrivateKeyParser.java#L59-L95","documentation":"PrivateKeyParser.getECParameterSpec maps an EC curve name/OID to java.security.spec ECParameterSpec by generating a throwaway keypair with KeyPairGenerator('EC') and ECGenParameterSpec. If the JCA provider cannot handle the curve (unknown name/OID, unsupported curve), the GeneralSecurityException is wrapped into VertxException('Cannot determine EC parameter spec for curve name/OID').","triggerScenarios":"Parsing a private key with an EC curve not supported by the JVM's providers (e.g. exotic/secp curves, curve OIDs unknown to the provider), or on a JVM lacking the EC provider.","commonSituations":"Keys generated with OpenSSL on unusual curves (e.g. secp256k1 on older JDKs), older JDKs without full EC support, FIPS providers with restricted curve sets.","solutions":["Use a JDK/provider that supports the curve (or upgrade the JDK)","Re-export the key on a widely supported curve (e.g. prime256v1, secp384r1, secp521r1)","Register a provider supporting the curve (e.g. BouncyCastle) via Security.addProvider"],"exampleFix":"// before\nopenssl ecparam -genkey -name secp256k1 -out key.pem\n// after\nopenssl ecparam -genkey -name prime256v1 -out key.pem  // or add BouncyCastle provider","handlingStrategy":"try-catch","validationCode":"try {\n  new ECGenParameterSpec(\"prime256v1\");\n  KeyPairGenerator.getInstance(\"EC\");\n} catch (Exception e) {\n  throw new IllegalStateException(\"EC provider/curve unavailable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  alg = PrivateKeyParser.getPKCS8EncodedKeyAlgorithm(der);\n} catch (VertxException e) {\n  // unsupported curve: re-export key on prime256v1/secp384r1 or add BouncyCastle\n}","preventionTips":["Generate keys on widely supported curves (prime256v1, secp384r1, secp521r1)","Avoid secp256k1 on JVMs without provider support","Register BouncyCastle if exotic curves are required"],"tags":["ec","curve","jca"],"backgroundTag":"unsupported-operation","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}