marciofmjr
4/23/2020 - 10:05 AM

Fix postgres SSL error connection

1 - Instalar postgres através do brew

2 - Executar os comandos para gerar o certificado

openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -key server.key -out server.csr

openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt

3 - Mover os certificados para a pasta do postgre

mv server.crt /usr/local/var/postgres
mv server.key /usr/local/var/postgres

4 - Habilitar SSL na config do postgres

sudo vi /usr/local/var/postgres/postgresql.conf

linha 100 + ou -

ssl = on
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'

5 - Ajustar permissão da chave

chmod 0600 server.key

6 - Reiniciar postgres