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 1mBKrX-0002nf-7Z for pgsql-general@arkaria.postgresql.org; Wed, 04 Aug 2021 17:39:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mBKqy-0008HF-6Z for pgsql-general@arkaria.postgresql.org; Wed, 04 Aug 2021 17:38:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBKqx-0008H7-Tb; Wed, 04 Aug 2021 17:38:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBKqv-00016q-A6; Wed, 04 Aug 2021 17:38:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 174Hcf852004796; Wed, 4 Aug 2021 13:38:41 -0400 From: Tom Lane To: M Tarkeshwar Rao cc: "pgsql-general@lists.postgresql.org" , "'pgsql-general@postgresql.org'" , Avinesh Kumar , Kirti Dhar Upadhyay K , Neeraj Gupta G Subject: Re: =?Windows-1252?Q?=93tlsv1_alert_unknown_ca=94_with_PQconnectdb?= In-reply-to: References: Comments: In-reply-to M Tarkeshwar Rao message dated "Wed, 04 Aug 2021 14:08:59 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2004794.1628098721.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 04 Aug 2021 13:38:41 -0400 Message-ID: <2004795.1628098721@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk M Tarkeshwar Rao writes: > I am trying psql with following options where I am providing client cert= ificates also. It is connected perfectly. > psql "host=3D 10.10.11.18 sslmode=3Dverify-ca sslrootcert=3Dem-ca-crt.pe= m sslcert=3Dem-client-crt.pem sslkey=3Dem-client-key.pem port=3D5433 user=3D= postgres dbname=3Dpostgres" You do realize that those certificate parameters are path names, right? > Same when we used with C api (PQconnectdb((const char *)str);) it is fai= ling with following error message. > =C2=93tlsv1 alert unknown ca=C2=94 I think the most likely theory is that libpq is failing to load the root cert because the program's current working directory isn't the same as where you had been running psql. It does look like libpq will complain if the given files aren't readable, so maybe the true situation is that it's finding files by those names but they aren't the right ones. In any case, you generally want to put absolute pathnames into these connection parameters. regards, tom lane