Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ihlI3-000883-AJ for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Dec 2019 02:11:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ihlI0-0005ka-U8 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Dec 2019 02:11:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ihlI0-0005kS-I8 for pgsql-hackers@lists.postgresql.org; Thu, 19 Dec 2019 02:11:44 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ihlHu-0007MB-3t for pgsql-hackers@lists.postgresql.org; Thu, 19 Dec 2019 02:11:44 +0000 Received: by mail-pj1-x102a.google.com with SMTP id j11so1753928pjs.1 for ; Wed, 18 Dec 2019 18:11:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=sRJbkBUEEdGBzFQ44ktRKQca66+YJbtSclYvY0msdZw=; b=b6krtTV57D4entZOujibVlIuPr9+gcesbnWHR4Wwjq7eEEX+TJjHmGngT0C6B0knfo 3HaV04Yewv5g9Qw2OK2XCVTaq/rI7KmsXDlyPQ6tMIkYqRgifxNkLkEp53b+Ijk31fLe mkMKjSpxTpFoUkB1IUnooTp6/7Ev1mf8bRXg8PZzNeMYk7OfkKXdSTZHPXPolw6bV2q7 gdJWafiB1RHfokhXd9FQoMeeQlI1I72fqmBDiMAKzYP4nhyjWMyky09hFwE14eSaZ5yx qqec3jI2xcSTAGaCVLcoZExcCNTcLhilOEiaCvwWdU7FUzMNf/pXQwEA100k0Mtuj3JB Wldw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sRJbkBUEEdGBzFQ44ktRKQca66+YJbtSclYvY0msdZw=; b=P13fzGCnQDAr5gfhn89UO3QT8FVPX9qfpGf/ll0Y3VF0XYUWEzZBBVEc7Y4GDaazv2 M+YG34efBz3/bKmQmUvgqH2xoiMHeDdXhPk6es2pNVfZy2Fm7FdNpMOQRbwzGqe+RZ6U Lgra1Zdzz+s5gMaZ8qgCCovfVAX0t1GUE/0pl8I/l9qHnm1P1C4kfeMGX3WNEsKT5rLu qOHPi4y/zEOl9M5UH0mhbMCJtVDzOd+LusFWFHTKtNGbivmT8IpJepl01rHcUHWdl7oF p2ezT1dsnrLkoZBouWEcY8cxD5FNZSDJkUdy8fylBsTijyvWDOmZJtUxBMvYBRtMlr+H btcA== X-Gm-Message-State: APjAAAVa6atvX+4ZHVDynaDn7IJE3nWqpvDmj7UmChqkoEDL74ZuYY4e QrrvsxQBmcsGOaUiuJpSbaj9dT6a3KA= X-Google-Smtp-Source: APXvYqwZU8npuUgcEVQQDQosmGhOI/xcpKeri1dTnG/jqKbm6OcyIESpfAAx4LQd5G7GP8MBaNQVaw== X-Received: by 2002:a17:90a:fb45:: with SMTP id iq5mr6535402pjb.93.1576721494359; Wed, 18 Dec 2019 18:11:34 -0800 (PST) Received: from [192.168.2.111] (113x32x180x194.ap113.ftth.ucom.ne.jp. [113.32.180.194]) by smtp.gmail.com with ESMTPSA id k60sm4697072pjh.22.2019.12.18.18.11.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Dec 2019 18:11:33 -0800 (PST) Subject: Re: Setting min/max TLS protocol in clientside libpq To: Daniel Gustafsson , PostgreSQL Hackers References: <4F246AE3-A7AE-471E-BD3D-C799D3748E03@yesql.se> From: Arthur Zakirov Message-ID: <0a0704fa-db1f-cedf-d0ce-eae30d984105@gmail.com> Date: Thu, 19 Dec 2019 11:11:31 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <4F246AE3-A7AE-471E-BD3D-C799D3748E03@yesql.se> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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