From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Marco Ippolito <ippolito.marco@gmail.com>
To: Martin Gainty <mgainty@hotmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: "Failed to connect to Postgres database"
Date: Thu, 26 Sep 2019 07:50:24 -0700
Message-ID: <84aea77f-d09e-d938-e904-ed7700856fa3@aklaver.com> (raw)
In-Reply-To: <CAFegzBQnwgx=+5DqRVrqBHBBpBRzapZrGB3DamCc4qdYUfOEOA@mail.gmail.com>
References: <CAFegzBQf-TH3BqWcL2MTq8hPyE3NLsHt6-LSLQLfYPeLu7tRdQ@mail.gmail.com>
<CH2PR19MB3893AC0F5133DF53B453BB01AE870@CH2PR19MB3893.namprd19.prod.outlook.com>
<CAFegzBRmMWTC2r0UN6VyOrLWWiLGK6TVbmUufx+vkFX9WxPDHg@mail.gmail.com>
<CAFegzBQnwgx=+5DqRVrqBHBBpBRzapZrGB3DamCc4qdYUfOEOA@mail.gmail.com>
On 9/26/19 7:21 AM, Marco Ippolito wrote:
> In order to restart from a clean situation and configuration, I removed
> the previous fabric-ca folder, created a new one, and then initiated the
> fabric-ca-server. With the default SQLite everything seem working fine.
> But one I try to use the PostgreSQL-11 db I created before, errors appear:
>
> |(base)marco@pc:~/fabric$rm -rf fabric-ca (base)marco@pc:~/fabric$mkdir
> fabric-ca (base)marco@pc:~/fabric$cd
> fabric-ca/(base)marco@pc:~/fabric/fabric-ca$fabric-ca-server init -b
> admin:adminpw (base)marco@pc:~/fabric/fabric-ca$fabric-ca-server start-b
> admin:adminpw 2019/09/2615:48:54[INFO]Created defaultconfiguration
> fileat /home/marco/fabric/fabric-ca/fabric-ca-server-config.yaml
> 2019/09/2615:48:54[INFO]Starting server inhome
> directory:/home/marco/fabric/fabric-ca 2019/09/2615:48:54[INFO]Server
> Version:1.4.42019/09/2615:48:54[INFO]Server
> Levels:&{Identity:2Affiliation:1Certificate:1Credential:1RAInfo:1Nonce:1}2019/09/2615:48:54[WARNING]&{69The
> specified CA certificate file/home/marco/fabric/fabric-ca/ca-cert.pem
> does notexist}2019/09/2615:48:54[INFO]generating key:&{A:ecdsa
> S:256}2019/09/2615:48:54[INFO]encoded CSR 2019/09/2615:48:54[INFO]signed
> certificate withserial number
> 1625953039820960683388734809875126848203422536642019/09/2615:48:54[INFO]The
> CA keyandcertificate were generated forCA 2019/09/2615:48:54[INFO]The
> keywas stored byBCCSP provider 'SW'2019/09/2615:48:54[INFO]The
> certificate isat:/home/marco/fabric /fabric-ca/ca-cert.pem
> 2019/09/2615:48:54[INFO]Initialized sqlite3 databaseat /home/marco
> /fabric/fabric-ca/fabric-ca-server.db 2019/09/2615:48:54[INFO]The issuer
> keywas successfully stored.The
> publickeyisat:/home/marco/fabric/fabric-ca/IssuerPublicKey,secret
> keyisat:/home/marco/fabric/fabric-ca/msp/keystore/IssuerSecretKey
> 2019/09/2615:48:54[INFO]Idemix issuer revocation publicandsecret keys
> were generated forCA ''2019/09/2615:48:54[INFO]The revocation keywas
> successfully stored.The publickeyisat:/home/marco/fabric/fabric-
> ca/IssuerRevocationPublicKey,private keyisat:/home/marco/fabric
> /fabric-ca/msp/keystore/IssuerRevocationPrivateKey
> 2019/09/2615:48:54[INFO]Home directory fordefaultCA:/home/marco
> /fabric/fabric-ca 2019/09/2615:48:54[INFO]Operation Server Listening
> on127.0.0.1:94432019/09/2615:48:54[INFO]Listening onhttp://0.0.0.0:7054|
>
> I set the brand-new fabric-ca-server-config.yaml in this way:
>
> |#db:#type:sqlite3 #datasource:fabric-ca-server.db #tls:#enabled:false
> #certfiles:#client:#certfile:#keyfile:db:type:postgres
> datasource:host=localhost port=5433user=fabmnet_admin password=password
> dbname=fabmnetdb sslmode=verify-full|
Shouldn't the TLS info also be there for the Postgres datasource:
https://hyperledger-fabric-ca.readthedocs.io/en/release-1.4/users-guide.html#postgresql
As to below, you will not get logs as you are never connecting to the
database. Those errors get sent to the console.
You are fighting two issues, role permissions and SSL certs. I would
deal with one a time. Drop the SSL requirement until you can verify a
connection and database creation. Then deal with the SSL issues.
>
> and in /etc/postgresql/11/fabmnet/postgresql.conf :
>
> |ssl =onssl_cert_file
> ='/home/marco/fabric/fabric-ca/ca-cert.pem'ssl_key_file
> ='/home/marco/fabric/fabric-ca/msp/keystore /IssuerSecretKey'|
>
> After systemctl restart postgresql, I tried to start the fabric-ca-server:
>
> |(base)marco@pc:~/fabric/fabric-ca$fabric-ca-server start-b
> admin:adminpw 2019/09/2615:56:50[INFO]Configuration
> filelocation:/home/marco /fabric/fabric-ca/fabric-ca-server-config.yaml
> 2019/09/2615:56:50[INFO]Starting server inhome
> directory:/home/marco/fabric/fabric-ca 2019/09/2615:56:50[INFO]Server
> Version:1.4.42019/09/2615:56:50[INFO]Server
> Levels:&{Identity:2Affiliation:1Certificate:1Credential:1RAInfo:1Nonce:1}2019/09/2615:56:50[INFO]The
> CA keyandcertificate already exist 2019/09/2615:56:50[INFO]The
> keyisstored byBCCSP provider 'SW'2019/09/2615:56:50[INFO]The certificate
> isat:/home/marco/fabric /fabric-ca/ca-cert.pem
> 2019/09/2615:56:50[WARNING]Failed
> toconnecttodatabase'fabmnetdb'2019/09/2615:56:50[WARNING]Failed
> toconnecttodatabase'postgres'2019/09/2615:56:50[WARNING]Failed
> toconnecttodatabase'template1'2019/09/2615:56:50[ERROR]Error occurred
> initializing database:Failed toconnecttoPostgres database.Postgres
> requires connecting toa specific database,the followingdatabases were
> tried:[fabmnetdb postgres template1].Please createone ofthese
> databasebefore continuing 2019/09/2615:56:50[INFO]Home directory
> fordefaultCA:/home/marco /fabric/fabric-ca
> 2019/09/2615:56:50[INFO]Operation Server Listening
> on127.0.0.1:94432019/09/2615:56:50[INFO]Listening onhttp://0.0.0.0:7054|
>
> Before I also removed all the previous content of
> /var/log/postgresql/postgresql-11-fabmnet.log to have a clean situation.
> But strangely now I do not get any new logging information in
> postgresql-11-fabmnet.log
>
> So. I think there must be something to fix in the interface between
> fabric-ca-server and PostgreSQL-11 db. In fabric-ca-server-config.yaml,
> in postgresql.conf, in both or somewhere else.
>
>
>
>
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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, mgainty@hotmail.com
Subject: Re: "Failed to connect to Postgres database"
In-Reply-To: <84aea77f-d09e-d938-e904-ed7700856fa3@aklaver.com>
References: <CAFegzBQf-TH3BqWcL2MTq8hPyE3NLsHt6-LSLQLfYPeLu7tRdQ@mail.gmail.com> <CH2PR19MB3893AC0F5133DF53B453BB01AE870@CH2PR19MB3893.namprd19.prod.outlook.com> <CAFegzBRmMWTC2r0UN6VyOrLWWiLGK6TVbmUufx+vkFX9WxPDHg@mail.gmail.com> <CAFegzBQnwgx=+5DqRVrqBHBBpBRzapZrGB3DamCc4qdYUfOEOA@mail.gmail.com> <84aea77f-d09e-d938-e904-ed7700856fa3@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