{"id":"a17b6e51bef06b70","repo":"jackc/pgx","slug":"failed-to-decode-sslkey","errorCode":null,"errorMessage":"failed to decode sslkey","messagePattern":"failed to decode sslkey","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/config.go","lineNumber":932,"sourceCode":"\t\t}\n\tcase \"verify-full\":\n\t\ttlsConfig.ServerName = host\n\tdefault:\n\t\treturn nil, errors.New(\"sslmode is invalid\")\n\t}\n\n\tif (sslcert != \"\" && sslkey == \"\") || (sslcert == \"\" && sslkey != \"\") {\n\t\treturn nil, errors.New(`both \"sslcert\" and \"sslkey\" are required`)\n\t}\n\n\tif sslcert != \"\" && sslkey != \"\" {\n\t\tbuf, err := os.ReadFile(sslkey)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to read sslkey: %w\", err)\n\t\t}\n\t\tblock, _ := pem.Decode(buf)\n\t\tif block == nil {\n\t\t\treturn nil, errors.New(\"failed to decode sslkey\")\n\t\t}\n\t\tvar pemKey []byte\n\t\tvar decryptedKey []byte\n\t\tvar decryptedError error\n\t\t// If PEM is encrypted, attempt to decrypt using pass phrase\n\t\tif x509.IsEncryptedPEMBlock(block) {\n\t\t\t// Attempt decryption with pass phrase\n\t\t\t// NOTE: only supports RSA (PKCS#1)\n\t\t\tif sslpassword != \"\" {\n\t\t\t\tdecryptedKey, decryptedError = x509.DecryptPEMBlock(block, []byte(sslpassword)) //nolint:ineffassign\n\t\t\t}\n\t\t\t// if sslpassword not provided or has decryption error when use it\n\t\t\t// try to find sslpassword with callback function\n\t\t\tif sslpassword == \"\" || decryptedError != nil {\n\t\t\t\tif parseConfigOptions.GetSSLPassword != nil {\n\t\t\t\t\tsslpassword = parseConfigOptions.GetSSLPassword(context.Background())\n\t\t\t\t}\n\t\t\t\tif sslpassword == \"\" {","sourceCodeStart":914,"sourceCodeEnd":950,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/config.go#L914-L950","documentation":"Error \"failed to decode sslkey\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/config.go:932 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}