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 1iDtFN-0000Up-Gu for pgsql-general@arkaria.postgresql.org; Fri, 27 Sep 2019 16:37:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDtFM-0000Ak-91 for pgsql-general@arkaria.postgresql.org; Fri, 27 Sep 2019 16:37:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDtFL-0000Ad-46 for pgsql-general@lists.postgresql.org; Fri, 27 Sep 2019 16:37:32 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iDtFH-00083a-Df for pgsql-general@lists.postgresql.org; Fri, 27 Sep 2019 16:37:29 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 5538553B; Fri, 27 Sep 2019 12:37:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 27 Sep 2019 12:37:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=r TpFv0Blo3UI9/n/sJ5MfwgfT0fRlKfxgOYpukzC9cg=; b=Wcz1gWa8JciZwT/dj OqCry3xXa1YRQdik+4PMMOILW1N90uIKMho6WuvHUo86Q/smpv9N5bqZ2wbXifDs oQCKMhx0R0kfc/T4NpirdgqYuX90QNoH5V8Vdl3HyuSUsgcGN+nKEUmYQiL2diYg h8i1J1j8jNLhN2+S8dZljd7MRwCWaHuSt1IyNMHBSYILZMUCDizbvLWAF341MbPb dP7qyRpMxpT+on5FSWT98a8mIK8yW5v/hQem/TkIfFBhKRfNGWL1ZbULb4Eh1xEN bArrSmfktiABDByzR6zWrGCCraZG2w4RKg+YlP9uoR3Xpm3Im24sXjxHZMinARMY eIwaA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=rTpFv0Blo3UI9/n/sJ5MfwgfT0fRlKfxgOYpukzC9 cg=; b=urHMyFBduGZAXbWESDwtSHAcYPfizcnmyDqqypQH+QMsCclz/g2RPcPgZ srPtj6C1YwOYWKFP9J3cnYW0QQolsmViLHdky7/7rtjFPjeCRGQEg1CPs+boKvvE ugPMpsVTAdvdBiwmuZtkCZJu4tZbo+rR7FYtgYK7ZbVeekOa8KIWQaT4jda6Eysa 5x9nBe9LWZHWcCzcSIfGQZTjSEmk0EbFgWjr7TAq6/8b4GvtaYQ7dfLcexk65HhC /wEXcbi37/6LMVR06/EqsxxRFTI+4kCFiIHxiqxC1WbyNSMAHsKpQVO8r5z304XA 1QxV7th4msT64EBzzxpF/EkU3+gnw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrfeeigddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgpdhrvggrughthhgvugho tghsrdhiohenucfkphephedtrdduleefrdduleeirddutdeinecurfgrrhgrmhepmhgrih hlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmnecuvehl uhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from ranger.suse (50-193-196-106-static.hfc.comcastbusiness.net [50.193.196.106]) by mail.messagingengine.com (Postfix) with ESMTPA id 3DDB0D6005B; Fri, 27 Sep 2019 12:37:24 -0400 (EDT) Subject: Re: "Failed to connect to Postgres database" To: Marco Ippolito , pgsql-general@lists.postgresql.org References: <5860c69b-8b16-43b0-ba90-0a0cc7598520@manitou-mail.org> From: Adrian Klaver Message-ID: <4841ddf2-4c93-5465-5cd3-82cd4389e2e8@aklaver.com> Date: Fri, 27 Sep 2019 09:37:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/27/19 8:20 AM, Marco Ippolito wrote: > Correction of my previous email : > > This is the correct ssl connection, not the one before via socket: A tip, when troubleshooting be as explicit as possible in your command line usage. So for below explicitly state the -d postgres -U postgres. This will save you issues with default values and environment values that you don't know about changing the command. This is not the issue here, just a heads up for future use. More below. > > (base) postgres@pc:~$ psql -p5433 -h localhost > Password for user postgres: > psql (11.5 (Ubuntu 11.5-1.pgdg18.04+1)) > SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: > 256, compression: off) > fabmnet_ca=# > > Anyway, I'm still struggling in understanding how to configure the ssh > connection of fabric-ca-server to fabmnet_ca database: > > This is what I set in fabric-ca-server-config.yaml : > > #db: > #  type: sqlite3 > #  datasource: fabric-ca-server.db > #  tls: > #      enabled: false > #      certfiles: > #      client: > #        certfile: > #        keyfile: > > > db: >   type: postgres >   datasource: host=localhost port=5433 user=postgres password=pwd > dbname=fabmnet_ca sslmode=verify-full For now I would drop the sslmode or set it to require. If I am following correctly, if you are cert authentication with fabric-ca: https://hyperledger-fabric-ca.readthedocs.io/en/release-1.4/users-guide.html#postgresql Then you need to fill in the certfile(s) sections. I know you have tls.enabled: false. I think that the server is taking the datasource as priority and trying a verify-full without the necessary cert information. That is why I suggested backing off on the SSL requirements to see if you can make a connection. For what the sslmode options means go here: https://www.postgresql.org/docs/11/libpq-connect.html#LIBPQ-PARAMKEYWORDS and search in page for sslmode. Plan B would be to fill in the certfile(s) information. As to your question below as to why the psql connection works. You are not specifying an sslmode to the connection so it defaults to a sslmode of: prefer (default) first try an SSL connection; if that fails, try a non-SSL connection There is no cert authentication going on in that case, so you connect. The connection is done using SSL, it just does not verify the cert. >   tls: >       enabled: false >       certfiles: >       client: >         certfile: >         keyfile: > > Initializing the fabric-ca-server gives "Failed to connect to Postgres > database" and in postgresql-11-fabmnet.log : sslv3 alert bad certificate > > (base) marco@pc:~/fabric/fabric-ca$ fabric-ca-server init -b admin:adminpw > 2019/09/27 17:07:27 [INFO] Configuration file location: > /home/marco/fabric/fabric-ca/fabric-ca-server-config.yaml > 2019/09/27 17:07:27 [INFO] Server Version: 1.4.4 > 2019/09/27 17:07:27 [INFO] Server Levels: &{Identity:2 Affiliation:1 > Certificate:1 Credential:1 RAInfo:1 Nonce:1} > 2019/09/27 17:07:27 [INFO] The CA key and certificate already exist > 2019/09/27 17:07:27 [INFO] The key is stored by BCCSP provider 'SW' > 2019/09/27 17:07:27 [INFO] The certificate is at: > /home/marco/fabric/fabric-ca/ca-cert.pem > 2019/09/27 17:07:27 [WARNING] Failed to connect to database 'fabmnet_ca' > 2019/09/27 17:07:27 [WARNING] Failed to connect to database 'postgres' > 2019/09/27 17:07:27 [WARNING] Failed to connect to database 'template1' > 2019/09/27 17:07:27 [ERROR] Error occurred initializing database: Failed > to connect to Postgres database. Postgres requires connecting to a > specific database, the following databases were tried: [fabmnet_ca > postgres template1]. Please create one of these database before continuing > 2019/09/27 17:07:27 [INFO] Home directory for default CA: > /home/marco/fabric/fabric-ca > 2019/09/27 17:07:27 [INFO] Initialization was successful > > /var/log/postgresql/postgresql-11-fabmnet.log : 2019-09-27 17:07:27.159 > CEST [6626] [unknown]@[unknown] LOG:  could not accept SSL connection: > sslv3 alert bad certificate > > Why it says "sslv3 alert bad certificate" if it's exactly the same > certificate used when connecting to the same database with ssl in > postgres environment as shown above? > > Marco -- Adrian Klaver adrian.klaver@aklaver.com