pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Marco Ippolito <ippolito.marco@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: "Failed to connect to Postgres database"
Date: Fri, 27 Sep 2019 12:39:51 -0700
Message-ID: <0afa1ddc-6c3e-a3cf-ebbf-a00f185b38d2@aklaver.com> (raw)
In-Reply-To: <CAFegzBThzypkG0tqzGybYF1_1N=CazMgnsnjftgdKveYTOMLTg@mail.gmail.com>
References: <CAFegzBRWs4TdvCz12Cw6ftEUbForA7mkAmZgw9s6-F6VJfieNw@mail.gmail.com>
	<5860c69b-8b16-43b0-ba90-0a0cc7598520@manitou-mail.org>
	<CAFegzBTtnGDhNWNF5J-bkJj9sbdxxxT0cxc0xjwQQZ03y3uusQ@mail.gmail.com>
	<d9ea0a7c-e9ad-e018-a78b-e25b982ed75d@aklaver.com>
	<CAFegzBRCFiVogrQfKXhejWVb6NBj99R4BGUg7nbH6V-VQz3zAg@mail.gmail.com>
	<CAFegzBR3quFrD=8xQE0SjWVpbgntpghwgQXt_WN6E2UNbt=Kpg@mail.gmail.com>
	<4841ddf2-4c93-5465-5cd3-82cd4389e2e8@aklaver.com>
	<CAFegzBThzypkG0tqzGybYF1_1N=CazMgnsnjftgdKveYTOMLTg@mail.gmail.com>

On 9/27/19 11:02 AM, Marco Ippolito wrote:
> Thank you very much Adrian.
> Two things:
> 
> 1)
>   Why if I just specify through port the cluster and the host connection 
> I connect correctly with SSL,
>   but if I specify also the database and the user it connects it doesn't 
> usel SSL connection, or at least it doesn't say it uses SSL? :


Can you show the contents of  pg_hba.conf file for the 11/fabmnet 
cluster. The file will be in:

/etc/postgresql/11/fabmnet/


More below.

> 
> 2)
> In fabric-ca-server-config.yaml
> 
>    a) if I set:
> 
>      db:
>        type: postgres
>        datasource: host=localhost port=5433 user=postgres password=1234 
> dbname=fabmnet_ca sslmode=allow

According to the fabric-ca docs, allow is not one of the valid values:

https://hyperledger-fabric-ca.readthedocs.io/en/release-1.4/users-guide.html#postgresql

"Specifying sslmode configures the type of SSL authentication. Valid 
values for sslmode are:

Mode 	Description
disable 	No SSL
require 	Always SSL (skip verification)
verify-ca 	Always SSL (verify that the certificate presented by the 
server was signed by a trusted CA)
verify-full 	Same as verify-ca AND verify that the certificate presented 
by the server was signed by a trusted CA and the server hostname matches 
the one in the certificate

"


>        tls:
>            enabled: false
>            certfiles:
>            client:
>              certfile:
>              keyfile:
> 
>      where sslmode=allow means "first try a non-SSL connection; if that 
> fails, try an SSL connection"

> 
>      /var/log/postgresql/postgresql-11-fabmnet.log  :
>          2019-09-27 19:43:14.194 CEST [3213] postgres@fabmnet_ca FATAL: 
>   client certificates can only be checked if a root certificate store is 
> available

The above tells me that the start is ignoring sslmode=allow and rolling 
over into a verification mode and there are no certs specified. Please 
do as requested as try sslmode=require.

More below.

> 
>    b) if I set:
>      db:
>        type: postgres
>        datasource: host=localhost port=5433 user=postgres password=1234 
> dbname=fabmnet_ca sslmode=disable
>        tls:
>          enabled: false
>          certfiles:
>          client:
>            certfile:
>            keyfile:
> 
> 

> 
>      /var/log/postgresql/postgresql-11-fabmnet.log :
>          2019-09-27 19:55:03.691 CEST [3313] postgres@fabmnet_ca ERROR: 
>   database "fabmnet_ca" already exists
>          2019-09-27 19:55:03.691 CEST [3313] postgres@fabmnet_ca 
> STATEMENT:  CREATE DATABASE fabmnet_ca

The fabmnet_ca database has already been created.

> 
> Does it mean that in order to use postgresql-11 with fabric-ca I have to 
> use only socket connection?
> And if this is the case, why?

No you connected to localhost, though without SSL. Try again with 
sslmode=require and I am pretty sure you will connect with SSL, but no 
cert verification.

> 
> Marco
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (19+ messages)  latest in thread

Message-ID: <0afa1ddc-6c3e-a3cf-ebbf-a00f185b38d2@aklaver.com>
Permalink:  ../0afa1ddc-6c3e-a3cf-ebbf-a00f185b38d2@aklaver.com/
Also on:    postgresql.org/message-id/0afa1ddc-6c3e-a3cf-ebbf-a00f185b38d2@aklaver.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-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, ippolito.marco@gmail.com
  Subject: Re: "Failed to connect to Postgres database"
  In-Reply-To: <0afa1ddc-6c3e-a3cf-ebbf-a00f185b38d2@aklaver.com>
  References: <CAFegzBRWs4TdvCz12Cw6ftEUbForA7mkAmZgw9s6-F6VJfieNw@mail.gmail.com> <5860c69b-8b16-43b0-ba90-0a0cc7598520@manitou-mail.org> <CAFegzBTtnGDhNWNF5J-bkJj9sbdxxxT0cxc0xjwQQZ03y3uusQ@mail.gmail.com> <d9ea0a7c-e9ad-e018-a78b-e25b982ed75d@aklaver.com> <CAFegzBRCFiVogrQfKXhejWVb6NBj99R4BGUg7nbH6V-VQz3zAg@mail.gmail.com> <CAFegzBR3quFrD=8xQE0SjWVpbgntpghwgQXt_WN6E2UNbt=Kpg@mail.gmail.com> <4841ddf2-4c93-5465-5cd3-82cd4389e2e8@aklaver.com> <CAFegzBThzypkG0tqzGybYF1_1N=CazMgnsnjftgdKveYTOMLTg@mail.gmail.com> <0afa1ddc-6c3e-a3cf-ebbf-a00f185b38d2@aklaver.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