{"record":{"id":"dba11e99426cb584","repo":"jackc/pgx","slug":"ssl-request-too-short","errorCode":null,"errorMessage":"ssl request too short","messagePattern":"ssl request too short","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgproto3/ssl_request.go","lineNumber":20,"sourceCode":"\nimport (\n\t\"encoding/binary\"\n\t\"encoding/json\"\n\t\"errors\"\n\n\t\"github.com/jackc/pgx/v5/internal/pgio\"\n)\n\nconst sslRequestNumber = 80877103\n\ntype SSLRequest struct{}\n\n// Frontend identifies this message as sendable by a PostgreSQL frontend.\nfunc (*SSLRequest) Frontend() {}\n\nfunc (dst *SSLRequest) Decode(src []byte) error {\n\tif len(src) < 4 {\n\t\treturn errors.New(\"ssl request too short\")\n\t}\n\n\trequestCode := binary.BigEndian.Uint32(src)\n\n\tif requestCode != sslRequestNumber {\n\t\treturn errors.New(\"bad ssl request code\")\n\t}\n\n\treturn nil\n}\n\n// Encode encodes src into dst. dst will include the 4 byte message length.\nfunc (src *SSLRequest) Encode(dst []byte) ([]byte, error) {\n\tdst = pgio.AppendInt32(dst, 8)\n\tdst = pgio.AppendInt32(dst, sslRequestNumber)\n\treturn dst, nil\n}\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgproto3/ssl_request.go#L2-L38","documentation":"SSLRequest.Decode guard: the message body is shorter than the 4 bytes needed to hold the SSL request code. Only reachable on the server side of a startup exchange receiving a truncated SSLRequest packet; the truncated input buffer is the faulty input.","triggerScenarios":"Thrown at pgproto3/ssl_request.go:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the client sends the complete 8-byte SSLRequest packet","Check the connection for truncation or premature close"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}