{"record":{"id":"a4285151ff872a86","repo":"golang/go","slug":"tls-internal-error-unknown-cipher-suite","errorCode":null,"errorMessage":"tls: internal error: unknown cipher suite","messagePattern":"tls: internal error: unknown cipher suite","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/crypto/tls/handshake_server_tls13.go","lineNumber":977,"sourceCode":"\tfinishedMsg := &finishedMsg{\n\t\tverifyData: hs.clientFinished,\n\t}\n\tif err := transcriptMsg(finishedMsg, hs.transcript); err != nil {\n\t\treturn err\n\t}\n\n\tc.resumptionSecret = hs.masterSecret.ResumptionMasterSecret(hs.transcript)\n\n\tif !hs.shouldSendSessionTickets() {\n\t\treturn nil\n\t}\n\treturn c.sendSessionTicket(false, nil)\n}\n\nfunc (c *Conn) sendSessionTicket(earlyData bool, extra [][]byte) error {\n\tsuite := cipherSuiteTLS13ByID(c.cipherSuite)\n\tif suite == nil {\n\t\treturn errors.New(\"tls: internal error: unknown cipher suite\")\n\t}\n\t// ticket_nonce, which must be unique per connection, is always left at\n\t// zero because we only ever send one ticket per connection.\n\tpsk := tls13.ExpandLabel(suite.hash.New, c.resumptionSecret, \"resumption\",\n\t\tnil, suite.hash.Size())\n\n\tm := new(newSessionTicketMsgTLS13)\n\n\tstate := c.sessionState()\n\tstate.secret = psk\n\tstate.EarlyData = earlyData\n\tstate.Extra = extra\n\tif c.config.WrapSession != nil {\n\t\tvar err error\n\t\tm.label, err = c.config.WrapSession(c.connectionStateLocked(), state)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":959,"sourceCodeEnd":995,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/crypto/tls/handshake_server_tls13.go#L959-L995","documentation":"An internal invariant was violated: the connection's negotiated cipher suite (c.cipherSuite) was not found by cipherSuiteTLS13ByID when attempting to send a session ticket. This should never occur in a correctly functioning TLS 1.3 connection because the cipher suite was already used throughout the handshake. It indicates memory corruption, a race condition mutating connection state, or a bug in the cipher suite negotiation path.","triggerScenarios":"Called from sendSessionTicket or sendSessionTickets after the handshake is complete. The c.cipherSuite field contains a value that cipherSuiteTLS13ByID doesn't recognize as a valid TLS 1.3 cipher suite. This is theoretically unreachable in normal operation.","commonSituations":"Internal Go runtime or crypto/tls bug; memory corruption from an unsafe pointer operation elsewhere; a custom fork of the TLS package that modified cipher suite registration; extremely rare race condition on connection state.","solutions":["This is an internal error — report it as a bug if using unmodified Go standard library.","If using a forked crypto/tls, verify all TLS 1.3 cipher suite IDs are properly registered in cipherSuiteTLS13ByID.","Check for data races with go test -race in the surrounding code.","Ensure no unsafe code is corrupting the Conn struct."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// This is an internal invariant violation; no pre-check can prevent it.\n// Verify cipher suite is valid at config time:\nfunc validateCipherSuites(suites []uint16) error {\n    for _, id := range suites {\n        if cipherSuiteTLS13ByID(id) == nil && isTLS13Suite(id) {\n            return fmt.Errorf(\"unregistered TLS 1.3 cipher suite: %04x\", id)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// If this error occurs, it's a bug — capture context and report\nif err := conn.Handshake(); err != nil {\n    if strings.Contains(err.Error(), \"internal error: unknown cipher suite\") {\n        // This should never happen with stock Go — report as bug\n        log.Printf(\"BUG: unknown cipher suite %04x during session ticket\", conn.cipherSuite)\n    }\n}","preventionTips":["Don't fork crypto/tls without keeping cipher suite registration consistent.","Report this immediately if using unmodified Go — it indicates a runtime bug.","Run go test -race to catch data races affecting connection state."],"tags":["tls","tls13","cipher-suite","internal-error","session-ticket","server-side"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}