Enable SSL TCP Connections for Postgresql 9.1

How can I enable a secure ssl connection for an postgresql 9.1 server.
1 answer

Solution for: Enable SSL TCP Connections for Postgresql 9.1

    1. set ssl to on in postgresql.conf.
    2. creating a Self-Signed Certificate:

    openssl req -new -text -out server.req
    openssl rsa -in privkey.pem -out server.key
    rm privkey.pem
    openssl req -x509 -in server.req -text -key server.key -out server.crt
    chmod og-rwx server.key

    This will create a server.key certificate which not need a password in order to start up.
    3. copy server.key to the server's data directory

source
developer.postgresql.org/pgdocs/postgres/ssl-tcp.html