{"record":{"id":"2b85e9f0f5e30df9","repo":"jackc/pgx","slug":"bad-ssl-request-code","errorCode":null,"errorMessage":"bad ssl request code","messagePattern":"bad ssl request code","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgproto3/ssl_request.go","lineNumber":26,"sourceCode":"\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\n// MarshalJSON implements encoding/json.Marshaler.\nfunc (src SSLRequest) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(struct {\n\t\tType            string\n\t\tProtocolVersion uint32\n\t\tParameters      map[string]string","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgproto3/ssl_request.go#L8-L44","documentation":"SSLRequest.Decode guard: the 4-byte request code in the message body does not equal the magic constant 80877103 that identifies an SSLRequest. The peer sent some other startup packet where an SSL request was expected; the mismatched request code is the faulty input.","triggerScenarios":"Thrown at pgproto3/ssl_request.go:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the client is sending the correct SSLRequest magic number","Check protocol framing — bytes may be misaligned from a prior malformed message"],"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"}