Closed
Description
Describe the bug
if i use an empty-file as the sslkey
, pgx will panic.
To Reproduce
create an empty file named key.key
then run this program:
package main
import (
"context"
"github.com/jackc/pgx/v5"
)
func main() {
pgx.Connect(context.Background(), "host=localhost sslkey=key.key sslcert=key.crt")
}
Expected behavior
pgx.Connect
should return an error, if the sslkey is an empty file, it should not panic.
Actual behavior
pgx.Connect
panics when sslkey is an empty file.
A clear and concise description of what actually happened.
Version
- Go:
go version go1.22.0 darwin/arm64
- PostgreSQL: postgres is not running
- pgx:
v5.5.3
Additional context
i think the problem is here:
Lines 723 to 728 in 5c63f64
pem.Decode()
will return an error, but it is not checked. then x509.IsEncryptedPEMBlock()
panics.