{"record":{"id":"5b469a1ee7c54f2a","repo":"golang/go","slug":"tls-initial-handshake-had-non-empty-renegotiation","errorCode":null,"errorMessage":"tls: initial handshake had non-empty renegotiation extension","messagePattern":"tls: initial handshake had non-empty renegotiation extension","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/crypto/tls/handshake_client.go","lineNumber":910,"sourceCode":"\n\tsupportsPointFormat := false\n\tofferedNonCompressedFormat := false\n\tfor _, format := range hs.serverHello.supportedPoints {\n\t\tif format == pointFormatUncompressed {\n\t\t\tsupportsPointFormat = true\n\t\t} else {\n\t\t\tofferedNonCompressedFormat = true\n\t\t}\n\t}\n\tif !supportsPointFormat && offeredNonCompressedFormat {\n\t\treturn false, errors.New(\"tls: server offered only incompatible point formats\")\n\t}\n\n\tif c.handshakes == 0 && hs.serverHello.secureRenegotiationSupported {\n\t\tc.secureRenegotiation = true\n\t\tif len(hs.serverHello.secureRenegotiation) != 0 {\n\t\t\tc.sendAlert(alertHandshakeFailure)\n\t\t\treturn false, errors.New(\"tls: initial handshake had non-empty renegotiation extension\")\n\t\t}\n\t}\n\n\tif c.handshakes > 0 && c.secureRenegotiation {\n\t\tvar expectedSecureRenegotiation [24]byte\n\t\tcopy(expectedSecureRenegotiation[:], c.clientFinished[:])\n\t\tcopy(expectedSecureRenegotiation[12:], c.serverFinished[:])\n\t\tif !bytes.Equal(hs.serverHello.secureRenegotiation, expectedSecureRenegotiation[:]) {\n\t\t\tc.sendAlert(alertHandshakeFailure)\n\t\t\treturn false, errors.New(\"tls: incorrect renegotiation extension contents\")\n\t\t}\n\t}\n\n\tif err := checkALPN(hs.hello.alpnProtocols, hs.serverHello.alpnProtocol, false); err != nil {\n\t\tc.sendAlert(alertUnsupportedExtension)\n\t\treturn false, err\n\t}\n\tc.clientProtocol = hs.serverHello.alpnProtocol","sourceCodeStart":892,"sourceCodeEnd":928,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/crypto/tls/handshake_client.go#L892-L928","documentation":"Per RFC 5746, on the very first handshake (c.handshakes == 0) when the server signals secure_renegotiation support, the renegotiation_info extension contents must be empty. If hs.serverHello.secureRenegotiation is non-empty on the initial handshake, the server is violating the protocol and the handshake fails with alertHandshakeFailure.","triggerScenarios":"Server sending non-empty renegotiation_info on the initial handshake; middlebox injecting data into the extension; corrupted ServerHello.","commonSituations":"Custom or outdated TLS stacks; rare in practice.","solutions":["Patch the server to comply with RFC 5746 (empty renegotiation_info on initial handshake).","Capture the ServerHello and report the defect to the server operator.","Investigate the path for tampering."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isInitialHandshakeNonEmptyReneg(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"initial handshake had non-empty renegotiation extension\")\n}","tryCatchPattern":"if _, err := tls.Dial(\"tcp\", addr, cfg); err != nil {\n    if isInitialHandshakeNonEmptyReneg(err) {\n        reportServerDefect(addr, err) // RFC 5746 violation\n    }\n}","preventionTips":["Report RFC 5746 violations to the server operator.","Investigate tampering on the path."],"tags":["tls","renegotiation","protocol","security"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}