I am trying to enable ssl connection and verify certificates for postgres running in a docker. I found this blog: postgres using ssl I followed some instructions from this and was able to connect via psql command. However, when I try to connect from my another application, it throws below error:
error: x509: cannot validate certificate for because it doesn't contain any IP SANs
I tried adding SAN to the client certificate:
openssl req -new -key client.key -subj "/CN=test" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=IP: ip address of docker ")) -out client.csr
and verified with the below command:
openssl req -in client.csr -text -noout
However, I still see the same problem as above "
doesn't contain IP SANs"
Would someone be able to point out what might be wrong here? Thanks!
Update: Below is the full set of commands I used to generate server and client keys and certificates:
openssl genrsa -des3 -out root.key 4096
openssl rsa -in root.key -out root.key
openssl req -new -x509 -days 365 -subj "/CN=postgres" -key root.key -out root.crt
openssl genrsa -des3 -out server.key 4096
openssl rsa -in server.key -out server.key
openssl req -new -key server.key -subj "/CN=" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=IP:ip address")) -text -out server.csr
openssl x509 -req -in server.csr -text -days 365 -CA root.crt -CAkey root.key -CAcreateserial -out server.crt
openssl genrsa -out client.key 4096
openssl rsa -in client.key -out client.key
openssl req -new -key client.key -subj "/CN=test" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=IP:ip address")) -out client.csr
openssl x509 -req -in client.csr -CA root.crt -CAkey root.key -CAcreateserial -days 365 -text -out client.crt