{"id":"4a16f2ee38f94e1f","repo":"jackc/pgx","slug":"both-sslcert-and-sslkey-are-required","errorCode":null,"errorMessage":"both \"sslcert\" and \"sslkey\" are required","messagePattern":"both \"sslcert\" and \"sslkey\" are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/config.go","lineNumber":922,"sourceCode":"\t\t\t\tRoots:         tlsConfig.RootCAs,\n\t\t\t\tIntermediates: x509.NewCertPool(),\n\t\t\t}\n\t\t\t// Skip the first cert because it's the leaf. All others\n\t\t\t// are intermediates.\n\t\t\tfor _, cert := range certs[1:] {\n\t\t\t\topts.Intermediates.AddCert(cert)\n\t\t\t}\n\t\t\t_, err := certs[0].Verify(opts)\n\t\t\treturn err\n\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)","sourceCodeStart":904,"sourceCodeEnd":940,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/config.go#L904-L940","documentation":"Error \"both \"sslcert\" and \"sslkey\" are required\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/config.go:922 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}