From 8896bd697781ed4aee392daa90b90cde142319fe Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 24 Feb 2024 09:24:26 -0600 Subject: [PATCH] Handle invalid sslkey file https://github.com/jackc/pgx/issues/1915 --- pgconn/config.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pgconn/config.go b/pgconn/config.go index ddde89bd5..33a722579 100644 --- a/pgconn/config.go +++ b/pgconn/config.go @@ -721,6 +721,9 @@ func configTLS(settings map[string]string, thisHost string, parseConfigOptions P return nil, fmt.Errorf("unable to read sslkey: %w", err) } block, _ := pem.Decode(buf) + if block == nil { + return nil, errors.New("failed to decode sslkey") + } var pemKey []byte var decryptedKey []byte var decryptedError error