CNs are important!!! -days 3650
umask u=rw,go= && openssl req -days 3650 -new -text -nodes -subj '/C=US/ST=Massachusetts/L=Bedford/O=Personal/OU=Personal/[email protected]/CN=localhost' -keyout server.key -out server.csr
umask u=rw,go= && openssl req -days 3650 -x509 -text -in server.csr -key server.key -out server.crt
umask u=rw,go= && cp server.crt root.crt
rm server.csr
umask u=rw,go= && openssl req -days 3650 -new -nodes -subj '/C=US/ST=Massachusetts/L=Bedford/O=Personal/OU=Personal/[email protected]/CN=chesco' -keyout client.key -out client.csr
umask u=rw,go= && openssl x509 -days 3650 -req -CAcreateserial -in client.csr -CA root.crt -CAkey server.key -out client.crt
rm client.csr
ssl = on
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'
ssl_ca_file = 'root.crt'
hostssl all all ::1/128 cert clientcert=1
hostssl all all 127.0.0.1/32 cert clientcert=1
#host all all 127.0.0.1/32 md5
#host all all 127.0.0.1/32 trust
#host all all ::1/32 trust
psql "host=localhost dbname=dbName user=chesco sslmode=verify-ca \
sslcert=client.crt \
sslkey=client.key \
sslrootcert=root.crt"
Thank you for creating gist, it works fine, but I wondering why didn't you use
v3_ca
extensions like PostgreSQL official documentations