pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Arthur Zakirov <zaartur@gmail.com>
To: Daniel Gustafsson <daniel@yesql.se>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Setting min/max TLS protocol in clientside libpq
Date: Thu, 19 Dec 2019 11:11:31 +0900
Message-ID: <0a0704fa-db1f-cedf-d0ce-eae30d984105@gmail.com> (raw)
In-Reply-To: <4F246AE3-A7AE-471E-BD3D-C799D3748E03@yesql.se>
References: <4F246AE3-A7AE-471E-BD3D-C799D3748E03@yesql.se>

Hello,

On 2019/12/04 2:37, Daniel Gustafsson wrote:
> The attached patch implements two new connection string variables for minimum
> and maximum TLS protocol version, mimicking how it's done in the backend.  This
> does duplicate a bit of code from be-secure-openssl.c to cope with older
> versions of OpenSSL, but it seemed a too trivial duplication to create
> common/openssl.c (but others might disagree).

I've looked at the patch and I have a couple comments.

> +		if (ssl_max_ver < ssl_min_ver)
> +		{
> +			printfPQExpBuffer(&conn->errorMessage,
> +							  libpq_gettext("invalid maximum SSL version specified, must be higher than minimum SSL version: %s\n"),
> +							  conn->sslmaxprotocolversion);
> +			return -1;
> +		}
> +
> +		if (ssl_max_ver == -1)
> +		{
> +			printfPQExpBuffer(&conn->errorMessage,
> +							  libpq_gettext("invalid maximum SSL version specified: %s\n"),
> +							  conn->sslmaxprotocolversion);
> +			return -1;
> +		}

I think we should raise the error "invalid maximum SSL version 
specified" earlier. If ssl_protocol_version_to_openssl() returns -1 and 
ssl_min_ver is valid we never reach the condition "ssl_max_ver == -1". 
Also it might confuse users to get the error "invalid maximum SSL 
version specified, must be higher than minimum SSL version" instead of 
former one.

Secondly I think the error "invalid maximum SSL version specified" 
itself might confuse users, in the case if the input is good but a build 
doesn't support desired version. So I think it is better to do two 
checks here: check for a correct input and check if a build supports it. 
In the second case we may raise "SSL version %s not supported by this 
build". It is actually like backend does: guc.c checks for correct input 
using ssl_protocol_versions_info and ssl_protocol_version_to_openssl() 
checks if a build supports the version.

-- 
Arthur





view thread (32+ messages)  latest in thread

Message-ID: <0a0704fa-db1f-cedf-d0ce-eae30d984105@gmail.com>
Permalink:  ../0a0704fa-db1f-cedf-d0ce-eae30d984105@gmail.com/
Also on:    postgresql.org/message-id/0a0704fa-db1f-cedf-d0ce-eae30d984105@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: zaartur@gmail.com, daniel@yesql.se
  Subject: Re: Setting min/max TLS protocol in clientside libpq
  In-Reply-To: <0a0704fa-db1f-cedf-d0ce-eae30d984105@gmail.com>
  References: <4F246AE3-A7AE-471E-BD3D-C799D3748E03@yesql.se> <0a0704fa-db1f-cedf-d0ce-eae30d984105@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox