Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kb9M5-00013T-EN for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Nov 2020 21:33:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kb9M4-0003aq-E3 for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Nov 2020 21:33:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kb8Ue-00053Z-46 for pgsql-hackers@lists.postgresql.org; Fri, 06 Nov 2020 20:37:56 +0000 Received: from mail-bn8nam11on2041.outbound.protection.outlook.com ([40.107.236.41] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kb8Ua-0000C1-SM for pgsql-hackers@lists.postgresql.org; Fri, 06 Nov 2020 20:37:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iu0GyfSHHCOGKeOov0LcumBEHgQjk42NqAiYfwTc1nfDc590nJXhF5adbp2QUKe6bZUoxsWiHUV26AaqU01PoHwbvoO3FO0M/R76gf8luq70AEiA/aiMbkE7tEbksCykU4r4AVEtafeqEo7kT7kZr5d+o9JgeP629bPDLnIQ72IFiFRHrhQKszcIsW12PMCdKxPwsIAMWfEmfqoGqFuYCoFkf7CmrBE6ETBd/WyQndXTY6KKclPfGE7AcQv/by81bQw7Kt1shBKIuJmSORWba8mZoJY6kTY3EbfhsPARctVzVntpgN+PFckgOMI4onpGA/rj5ol9BNIA29/OTG8Eow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eLQ6WJ3Et15sxqXfWkeI9GTTBKjfIonsIISN3OCidz8=; b=YzkkON6aiIzYhsrIRgp0+m2s8x/NSwxGWOFUJ8wMQTslACZhkEP/J1lf+cIltwXEASiVUHpdsM3ZEne9jNUbI+TMGuKeaJ860Gkh6ecukEVGzM5JkRFtzFEpqzMPIxQZ6CRdX7o21pPoXZn30rTlgXe2eP5NYfVxnmPT0nir9zfBROqRhzkr9b7rsplwOdtKJKV26SaUZv9RSpOg6ll1rukX2DdmJQ7K/yY4VBbtWLPUymV0hm4WCxOMxdQz0jnh+kT9GffHk3RS2EbKIFbA78L1GH20WPd30JTNGofsbbzgphgIi9FPyd3aXBkOMoWsNN3/10oXzBv8eaNIkFmk3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eLQ6WJ3Et15sxqXfWkeI9GTTBKjfIonsIISN3OCidz8=; b=aHZenB7IFQeGTDauoJIkmk6gVDCxaPA6qHP82eImKTR/ePMupIFooPUadVX/xWdgVYfOkTPe6tAC/X0kDgxN+yDOCyawv5jX0dQ1u/TLPRYjmLPlE50zlr1RH5mgsa5Kkm2NigqtG3HM9aogwv+NZ4ZWdi2IQSYHvIWZeVgSAoM= Received: from MWHPR05MB2957.namprd05.prod.outlook.com (2603:10b6:300:60::11) by MWHPR0501MB3724.namprd05.prod.outlook.com (2603:10b6:301:7a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.10; Fri, 6 Nov 2020 20:37:48 +0000 Received: from MWHPR05MB2957.namprd05.prod.outlook.com ([fe80::9442:1658:3abc:3fd3]) by MWHPR05MB2957.namprd05.prod.outlook.com ([fe80::9442:1658:3abc:3fd3%12]) with mapi id 15.20.3541.010; Fri, 6 Nov 2020 20:37:48 +0000 From: Jacob Champion To: Daniel Gustafsson CC: Heikki Linnakangas , Andres Freund , Postgres hackers , Michael Paquier , Andrew Dunstan , Stephen Frost , Thomas Munro Subject: Re: Support for NSS as a libpq TLS backend Thread-Topic: Support for NSS as a libpq TLS backend Thread-Index: AQHWM1w61GrKUIsl6UCBcYrYNRBt46kJRsIAgAA+PQCAGQsiAIAEdGUAgAAqk4CAAbpsAIABgI0AgCnqVACAA5UBgIAAY+MAgBTX7ACAACGAAIASngCAgAAfeICABYLFgIAbyjgAgABy24CACw63gIAAAzWAgAwa5QCAA6HPgA== Date: Fri, 6 Nov 2020 20:37:48 +0000 Message-ID: <0E64F3CB-4731-4FA8-82D8-D8590086654C@vmware.com> References: <20200904012334.GF19499@paquier.xyz> <20200917074134.GX2873@paquier.xyz> <20200929055939.GF7117@paquier.xyz> <411593A7-E037-474D-BFD7-D3D6683C1D46@yesql.se> <20201020191529.5yverw3ybaube3pg@alap3.anarazel.de> <907FA7D1-9BD9-464B-A6EC-DEEB53438D36@yesql.se> <7ed636a0-872c-3ea7-dc44-b35dd515bb87@iki.fi> <02260088-E0C9-49A2-ACD3-CE51D65A84E3@yesql.se> In-Reply-To: <02260088-E0C9-49A2-ACD3-CE51D65A84E3@yesql.se> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3445.104.15) authentication-results: yesql.se; dkim=none (message not signed) header.d=none;yesql.se; dmarc=none action=none header.from=vmware.com; x-originating-ip: [50.39.198.229] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1a0d2e4c-6cc1-4beb-eed6-08d88293d2d9 x-ms-traffictypediagnostic: MWHPR0501MB3724: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xVWJqT55M+xZXbVG9qEwHMgeZXgT/O5OeeYlWcNcxjZsxSeaK0gqLnmL1O4EPwUv5jbpTNmNNdyk/81walU0JBgtJaewh5GQQ3y0Coi8VcmYn8ky6jsS1tuCaXb1aMTy5UgQGzzuHbRWPsx6We2nbyY2ndW5uDosSsOBl3K1qLpVEHqq8dWmS0Ik7cxhe+o6Pk7l3Z3zOxylRsUeo1aiPMvoBOK7SLJoYUiMHRHdnEUEf6eHXG2SzbE+/c/ApY5mGtaTYLycxvWm/pb/04JH7VyHBr/Czr1cQurDWs01levA4uyIH286qKvCD9EW1Tik0CNKxBXs8h12Kt6jz6IyijC4nUxnm34cSQKPr9NjaT5lBzUfSgkz1ctkD2jYe+CjtUd+nvl4qNoFpO70R9saKQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR05MB2957.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(376002)(346002)(396003)(366004)(136003)(39860400002)(36756003)(33656002)(83380400001)(76116006)(66946007)(316002)(66556008)(6916009)(966005)(4326008)(6506007)(26005)(66446008)(2616005)(6512007)(91956017)(186003)(2906002)(54906003)(8676002)(53546011)(71200400001)(86362001)(478600001)(5660300002)(6486002)(64756008)(8936002)(66476007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: HACEc0ygA9VmTwy9cT26N4EG3qjC2/0B8FfVqYKyvuzfkYxDbltOB8lk7gROXlc3c4plc49zf5CqP5QCITvgT+usEYGPAcc8BSH47biPtM9Qk/OjmBVs1Fg7t6yvzx5LGE77tBwZMjbPnMpseITtnzV0+S+8EB8kTeO3Q/Dc5h5MHBaJoZP4jzBVj/823t1GGCq5tS0rrOL4IBv8zyxMzYvTd9Ysv+NOSRBeNhvNgkb3cQZ72eIzC1UE+QoDBFRcBShsU7r+X/QGJ/deuP6WUdaGyj+HYNMhqXVekFsqwXkutLBeGRNgRUPy6kQTYjkFQu9mQ74GRImoqPFEmKbkXdTayngqiYgM/mvPXbmc9CbqEsfAHUjrptLFqDUxFU2XIXdURDN5EBLLR/YOfTExBuXnmOGKiFasZC2TfUKwBJdq27gmScxP5WhBWdOM9xyx2S5QEJFBru/1SVAI6yrPV7VPVz6O3SHbhN6LdkR+0OhU7cKp+/whv0q7qyD7mZd44qz2sxv6RtXVCtL9oBPqFNvBd710Ekuo6wQh6HO7UPg8PZXCh7sXoBF9kmKNPuGcm1Dx48KZSKl3YXbTpEcoJxfvWX9hiQQMJ/t3OmBxnm1Cau8PILPo9RjS/GGi2KmOiQ0zj4oUVkC+Wj01/A04wpG1qZC11gK9BoaAmlxL5CLMk3GEDpsut4TW0BcFWkA4rGa/tOoCVssjCtmsdEqeiUd+Qn+zkwDZUfjDkTQehxEG4ogjtQ1I0A7ndLvdCNlWeTIO4osi6R52auqYYY+iVnCASVWDrrLODEJZn04BKKoq2TyP/F4PPZvEsxRiVxvhG/DzZH8BIVe8ihJSKcj6HjPuXNdJTDyWo2tdr9UfRCYXr40pO6ULUBNfYEENi6aTVs5AfWXl9+txKmRwCAzgrw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-ID: <23F1506C58575B40A8999D77E9534380@namprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR05MB2957.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a0d2e4c-6cc1-4beb-eed6-08d88293d2d9 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2020 20:37:48.1576 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: m0oSh0EyETJaPgfEBvz/omMnbZ+wlSj9MHpyTOFgxHBXM7+kA+C5h3ZhH3i5G6IfdQADuCDcXExuWZb132V3Xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0501MB3724 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Nov 4, 2020, at 5:09 AM, Daniel Gustafsson wrote: > (sorry for slow response). You are absolutely right, the has_password fl= ag > must be tracked per connection in PGconn. The attached v17 implements th= is as > well a frontend bugfix which caused dropped connections and some smaller = fixups > to make strings more translateable. Some initial notes from building and testing on macOS Mojave. I'm working w= ith both a brew-packaged NSS/NSPR (which includes basic nss-/nspr-config) and a hand-built NSS/NSPR (which does not). 1. In configure.ac: > + LDFLAGS=3D"$LDFLAGS $NSS_LIBS $NSPR_LIBS" > + CFLAGS=3D"$CFLAGS $NSS_CFLAGS $NSPR_CFLAGS" > + > + AC_CHECK_LIB(nss3, SSL_VersionRangeSet, [], [AC_MSG_ERROR([library 'ns= s3' is required for NSS])]) Looks like SSL_VersionRangeSet is part of libssl3, not libnss3. So this fai= ls with the hand-built stack, where there is no nss-config to populate LDFLAGS= . I changed the function to NSS_InitContext and that seems to work nicely. 2. Among the things to eventually think about when it comes to configuring,= it looks like some platforms [1] install the headers under and instead of and . It's unfortunate that the N= SS maintainers never chose an official installation layout. 3. I need two more `#define NO_NSPR_10_SUPPORT` guards added in both src/include/common/pg_nss.h src/port/pg_strong_random.c before the tree will compile for me. Both of those files include NSS header= s. 4. be_tls_init() refuses to run correctly for me; I end up getting an NSPR assertion that looks like sslMutex_Init not implemented for multi-process applications ! With assertions disabled, this ends up showing a somewhat unhelpful FATAL: unable to set up TLS connection cache: security library failure. = (SEC_ERROR_LIBRARY_FAILURE) It looks like cross-process locking isn't actually enabled on macOS, which = is a long-standing bug in NSPR [2, 3]. So calls to SSL_ConfigMPServerSIDCache() error out. --Jacob [1] https://github.com/erthink/ReOpenLDAP/issues/112 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=3D538680 [3] https://bugzilla.mozilla.org/show_bug.cgi?id=3D1192500