{"record":{"id":"f37dfa5a2b2f5efa","repo":"golang/go","slug":"tls-internal-error-supportscurve-accepted-unimpl-f37dfa","errorCode":null,"errorMessage":"tls: internal error: supportsCurve accepted unimplemented curve","messagePattern":"tls: internal error: supportsCurve accepted unimplemented curve","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/crypto/tls/key_agreement.go","lineNumber":170,"sourceCode":"\t// and generateServerKeyExchange.\n\tcurveID            CurveID\n\tsignatureAlgorithm SignatureScheme\n\tkey                *ecdh.PrivateKey\n}\n\nfunc (ka *ecdheKeyAgreement) generateServerKeyExchange(config *Config, cert *Certificate, clientHello *clientHelloMsg, hello *serverHelloMsg) (*serverKeyExchangeMsg, error) {\n\tfor _, c := range clientHello.supportedCurves {\n\t\tif config.supportsCurve(ka.version, c) {\n\t\t\tka.curveID = c\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ka.curveID == 0 {\n\t\treturn nil, errors.New(\"tls: no supported elliptic curves offered\")\n\t}\n\tif _, ok := curveForCurveID(ka.curveID); !ok {\n\t\treturn nil, errors.New(\"tls: internal error: supportsCurve accepted unimplemented curve\")\n\t}\n\n\tkey, err := generateECDHEKey(config.rand(), ka.curveID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tka.key = key\n\n\t// See RFC 4492, Section 5.4.\n\tecdhePublic := key.PublicKey().Bytes()\n\tserverECDHEParams := make([]byte, 1+2+1+len(ecdhePublic))\n\tserverECDHEParams[0] = 3 // named curve\n\tserverECDHEParams[1] = byte(ka.curveID >> 8)\n\tserverECDHEParams[2] = byte(ka.curveID)\n\tserverECDHEParams[3] = byte(len(ecdhePublic))\n\tcopy(serverECDHEParams[4:], ecdhePublic)\n\n\tpriv, ok := cert.PrivateKey.(crypto.Signer)","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/crypto/tls/key_agreement.go#L152-L188","documentation":"An internal invariant violation: config.supportsCurve returned true for a curve ID, but curveForCurveID could not map that same curve ID to an actual elliptic curve implementation. This means supportsCurve is accepting a curve that generateECDHEKey cannot handle. This error indicates a bug in the crypto/tls package itself — supportsCurve and curveForCurveID are out of sync.","triggerScenarios":"Theoretically unreachable in a correctly functioning standard library. Would fire if someone added a CurveID to the supported list in supportsCurve but forgot to register it in curveForCurveID, or vice versa.","commonSituations":"A forked or modified crypto/tls package where supportsCurve and curveForCurveID were updated inconsistently; a build from a corrupted or incomplete source tree; extremely unlikely with stock Go.","solutions":["If using a stock Go installation, report this as a Go runtime bug.","If using a forked crypto/tls, verify that every curve accepted by supportsCurve has a corresponding entry in curveForCurveID.","Rebuild from a clean source tree to rule out corruption.","Check that the Go version is not from a broken or experimental build."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Internal invariant — no pre-check is possible.\n// Verify you're using an unmodified Go standard library:\nfunc checkGoTLSVersion() error {\n    // This error should never occur with stock Go\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// If this fires, it's a bug in the crypto/tls package or a fork\nif err := conn.Handshake(); err != nil {\n    if strings.Contains(err.Error(), \"supportsCurve accepted unimplemented curve\") {\n        log.Printf(\"BUG: internal curve registry inconsistency: %v\", err)\n        // Report to Go team if using stock Go\n    }\n}","preventionTips":["Use unmodified Go standard library.","If forking crypto/tls, keep supportsCurve and curveForCurveID in sync.","Report immediately if seen with stock Go.","Verify build integrity if this error appears."],"tags":["tls","tls12","ecdhe","internal-error","curves","server-side"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}