sslmode=require fallback

From: Jakob Egger <jakob(at)eggerapps(dot)at>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: sslmode=require fallback
Date: 2016-06-16 08:39:00
Message-ID: 2A5EFBDC-41C6-42A8-8B6D-E69DA60E9962@eggerapps.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

I've looked at the way libpq handles TLS certificates and plaintext fallback, and I am somewhat surprised.

The default ssmode is prefer. According to the documentation, this will make libpq use an SSL connection if possible, but will use a plain text connection as a fallback. The certificate will not be verified.

If, however, there is a root certificate in ~/.postgresql/root.crt, libpq will check if the server cert matches this certificate, and refuse any certfificates that don't match. This means that libpq will fall back to a plain text connection!

This is very unexpected behavior! Shouldn't libpq prefer an *unauthenticated but encrypted* connection over an *unauthenticated and unencrypted* connection?

This behavior also causes sslmode=require to behave like sslmode=verify-ca when ~/.postgresql/root.crt exists.

From my limited understanding, it seems the way to fix this would be in fe-secure-openssl.c, to change initialize_SSL() to only read the root certificate file when sslmode=verify_*

However, if this is the expected behavior, the documentation at https://www.postgresql.org/docs/current/static/libpq-ssl.html <https://www.postgresql.org/docs/current/static/libpq-ssl.html> should be updated to make this more clear. It should be made clear that the existence of the file ~/.postgresql/root.crt changes the behavior of sslmode=require and sslmode=prefer.

Best regards,
Jakob

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2016-06-16 08:42:56 Re: sslmode=require fallback
Previous Message Amit Kapila 2016-06-16 07:28:58 Re: Hash Indexes