Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpXw0-0004je-Bx for pgsql-admin@arkaria.postgresql.org; Tue, 14 Aug 2018 11:56:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpXvy-0003FS-Cs for pgsql-admin@arkaria.postgresql.org; Tue, 14 Aug 2018 11:56:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpXvy-0003FL-2W for pgsql-admin@lists.postgresql.org; Tue, 14 Aug 2018 11:56:22 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fpXvu-00039Q-AM for pgsql-admin@lists.postgresql.org; Tue, 14 Aug 2018 11:56:21 +0000 Received: by mail-wr1-x442.google.com with SMTP id f12-v6so16930615wrv.12 for ; Tue, 14 Aug 2018 04:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:thread-index:content-language; bh=L2EL+CsE9IbghY5Hfw/LtTdX6aGy9SgOHXREWH5CyVw=; b=QxAUJTylphRdE30CJAnSlVxrOVwQ5+FEjnE0pdsvl7yfBkTu7yRjTwsifaC3LTlin/ qux1zR+5RZiSpP8Y5XaUegtS78Wk/dcCWoAnWG9n65u+j9zplbydoYA536xtAARGRalO 5bPrwf+92RMTTg6p0T/hORqKUA1QpNMu/ZIT139Jzgaf/ILTmYfeyAeKkpv4wBJZQh05 bUFU2+zRnHlXnTumJ1cvxTdLRBeJh81C+gM1n1Kww0Z5R9d+TtnIAtQc8SidzNbyuMvj 6zq/ZtpKo5cwL9ygI3P+H1+DwknIbZ5xnFQWeQKzXvTIJvuSgmO5wEEFiPJLz+DCJUTV 4BGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:thread-index:content-language; bh=L2EL+CsE9IbghY5Hfw/LtTdX6aGy9SgOHXREWH5CyVw=; b=ik14m1eZcaO9c9WxbN4V1LYCNI2Z/ek73ZtYlLoBaMNjQPaIV/dSxufHXuFEWtoSdw S3RozLsGfZzbeGRLAj7htZ42jN/8kuCbsFqKWATpCeuFdy2cUwZ1AifzU1usP8hhZt4B RarWse/J5NXBIFAl/wJEOIQ4Yx8UrBYPVOzDUIf6P7o/l7zbnaQ8Qo1xoRDxbyAePL8x A/JRSG8tZK9lnLIlv+Oh3jgSNkK9sF2Es9/z1DjD8XG0j4enKV1kpOxjA93VrqWHROE5 82gNVHq94Qp5Kvq8HwJZ5fvYj8t47+njuM7s/I9MiRYO5xrS4LdEATXC7tBx1Riuyatn Xvcg== X-Gm-Message-State: AOUpUlGkAZrhi6QXUHL5FZN96DBG4HwrQ/KH5SFHXx8vuvOPFrbBJwUq ijlX+rqgkMeCurTyd+r3fM5/VpUxoWg= X-Google-Smtp-Source: AA+uWPzsP86uD6jw+KidoeqP/54U+JSUW0VXXY3aacewp4+2PRobel814EgfHo5cL77AdxFgvni2wA== X-Received: by 2002:adf:9405:: with SMTP id 5-v6mr13559562wrq.129.1534247777276; Tue, 14 Aug 2018 04:56:17 -0700 (PDT) Received: from LAPTOPE7EH7MDP (167.221-30-62.static.virginmediabusiness.co.uk. [62.30.221.167]) by smtp.gmail.com with ESMTPSA id b6-v6sm23918529wru.66.2018.08.14.04.56.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 04:56:16 -0700 (PDT) From: "Mark Williams" To: "'Bear Giles'" Cc: References: <032401d43326$6c275d80$44761880$@gmail.com> <034901d4333f$d2aa7650$77ff62f0$@gmail.com> In-Reply-To: Subject: RE: Setting up SSL for postgre Date: Tue, 14 Aug 2018 12:56:16 +0100 Message-ID: <03d701d433c5$cf1c76b0$6d556410$@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_03D8_01D433CE.30E2B370" X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQJ64nPKQfAewiPZ9t7gQ7SiT+1fnwIMhi/1AcD6KUcCiXXq5aM+/62g Content-Language: en-gb List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multipart message in MIME format. ------=_NextPart_000_03D8_01D433CE.30E2B370 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, =20 The CN is =E2=80=9Cwww-data=E2=80=9D as per the howtoforge documentation = and added to the pg_hba.conf file. Do I have to add an actual user = called =E2=80=9Cwww-data=E2=80=9D to the database? =20 If so, do I have to have a different root and client certificate for = every ssl user? =20 Re pg_ident. I have added =E2=80=9Ccert www-data=E2=80=9D = Postgres=E2=80=9D to pg_ident. Doesn=E2=80=99t help. Still getting the = =E2=80=9Cconnection requires a valid client certificate=E2=80=9D error. =20 Thanks =20 Mark =20 __ =20 From: Bear Giles =20 Sent: 13 August 2018 21:57 To: Mark Williams Cc: pgsql-admin@lists.postgresql.org Subject: Re: Setting up SSL for postgre =20 It never hurts to double check. =20 What is the CN on the client cert? Is there a corresponding user in the = database? You might need to add an entry in pg_ident.conf, e.g., =20 cert bob@example.com bob =20 if you want user with the cert with a CN of ' = bob@example.com' to access the system as the postgresql user 'bob'. You = won't need this if your CN is the same as the database user. I've only = set up Kerberos authentication, not X.509 cert authentication, so I = don't know the details about what this file needs specifically. =20 Bear =20 =20 On Mon, Aug 13, 2018 at 1:57 PM, Mark Williams > wrote: What do you mean by =E2=80=9Cchange the ssl cert file and key=E2=80=9D =20 Pg_hba.conf =20 # TYPE DATABASE USER CIDR-ADDRESS METHOD =20 # IPv4 local & remote connections: host all all 127.0.0.1/32 = trust hostssl all www-data 0.0.0.0/0 = md5 clientcert=3D1 hostssl all postgres 0.0.0.0/0 = md5 clientcert=3D1 =20 # IPv6 local connections: host all all ::1/128 trust =20 Postgresql.conf ssl =3D on #ssl_ciphers =3D 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers #ssl_prefer_server_ciphers =3D on #ssl_ecdh_curve =3D 'prime256v1' #ssl_dh_params_file =3D '' ssl_cert_file =3D 'server.crt' ssl_key_file =3D 'server.key' ssl_ca_file =3D 'root.crt' #ssl_crl_file =3D '' =20 Thanks __ =20 From: Bear Giles < bgiles@coyotesong.com> = Sent: 13 August 2018 20:01 To: Mark Williams < = markwillimas@gmail.com> Cc: = pgsql-admin@lists.postgresql.org Subject: Re: Setting up SSL for postgre =20 What's in pg_hba.conf? =20 What's in postgresql.conf? Did you remember to change the ssl cert file = and key? For authentication I think you might need to set the SSL ca = file as well but I'm not sure. =20 =20 On Mon, Aug 13, 2018 at 10:55 AM, Mark Williams > wrote: I am new to Postgre. Migrating from MySQL. =20 I am trying to connect via SSL to a PostgreSQL using FireDac in Delphi. = I have followed the instructions at the following site: = = https://www.howtoforge.com/postgresql-ssl-certificates to create my = self-certified certificates and configure the config files. =20 I have coped the specified files to the client machine and installed the = root.crt certificate. Via FireDAC's connection params I have specified the following: Params.values[SSL_ca']:=3DsslCertsPath+'root.crt'; Params.values['SSL_cert']:=3DsslCertsPath+'postgresql.crt.'; Params.values['SSL_key']:=3DsslCertsPath+'postgresql.key'; =20 I am getting a connection error re invalid client certificate.=20 I have used OpenSSL to verify against the root.crt and postgresql.crt = and this confirms the certificate is ok. Mark =20 __ =20 =20 =20 ------=_NextPart_000_03D8_01D433CE.30E2B370 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Hi,

 

The CN is = =E2=80=9Cwww-data=E2=80=9D as per the howtoforge documentation and added = to the pg_hba.conf file. Do I have to add an actual user called = =E2=80=9Cwww-data=E2=80=9D to the database?

 

If so, do I = have to have a different root and client certificate for every ssl = user?

 

Re = pg_ident. I have added =E2=80=9Ccert www-data=E2=80=9D Postgres=E2=80=9D = to pg_ident. Doesn=E2=80=99t help. Still getting the =E2=80=9Cconnection = requires a valid client certificate=E2=80=9D = error.

 

Thanks

 

Mark

 

__

 

From: Bear Giles <bgiles@coyotesong.com>
Sent: = 13 August 2018 21:57
To: Mark Williams = <markwillimas@gmail.com>
Cc: = pgsql-admin@lists.postgresql.org
Subject: Re: Setting up SSL = for postgre

 

It never hurts to = double check.

 

What is the CN on = the client cert? Is there a corresponding user in the database? You = might need to add an entry in pg_ident.conf, = e.g.,

 

  =  cert   bob@example.com  =  bob

 

if you want user = with the cert with a CN of 'bob@example.com' to access the = system as the postgresql user 'bob'. You won't need this if your CN is = the same as the database user. I've only set up Kerberos authentication, = not X.509 cert authentication, so I don't know the details about what = this file needs specifically.

 

Bear

 

 

On Mon, = Aug 13, 2018 at 1:57 PM, Mark Williams <markwillimas@gmail.com> = wrote:

What do you = mean by =E2=80=9Cchange the ssl = cert file and key=E2=80=9D

 

Pg_hba.co= nf

 <= /o:p>

# = TYPE  DATABASE        = USER            = CIDR-ADDRESS          &= nbsp; METHOD

 <= /o:p>

# IPv4 = local & remote connections:

host &n= bsp;  = all           &nbs= p; = all           &nbs= p; 127.0.0.1/32      &nb= sp;     trust

hostssl = all         = www-data    0.0.0.0/0       =       md5 clientcert=3D1

hostssl = all         = postgres    0.0.0.0/0       =       md5 clientcert=3D1

 <= /o:p>

# IPv6 = local connections:

host &n= bsp;  = all           &nbs= p; = all           &nbs= p; = ::1/128           =       trust

 <= /o:p>

Postgresq= l.conf

ssl =3D = on

#ssl_ciphers= =3D 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers

#ssl_prefer_= server_ciphers =3D on

#ssl_ecdh_cu= rve =3D 'prime256v1'

#ssl_dh_para= ms_file =3D ''

ssl_cert_fil= e =3D 'server.crt'

ssl_key_file= =3D 'server.key'

ssl_ca_file = =3D 'root.crt'

#ssl_crl_fil= e =3D ''

 <= /o:p>

Thanks<= /o:p>

__

 <= /o:p>

From: Bear Giles = <bgiles@coyotesong.com> =
Sent: 13 August 2018 20:01
To: Mark Williams = <
markwillimas@gmail.com>
Cc:
pgsql-admin@lists.postgresql.org
Subject: Re: Setting up SSL for = postgre

 <= /o:p>

What's in = pg_hba.conf?

 <= /o:p>

What's in = postgresql.conf?  Did you remember to change the ssl cert file and = key? For authentication I think you might need to set the SSL ca file as = well but I'm not sure.

 <= /o:p>

 <= /o:p>

On Mon, Aug = 13, 2018 at 10:55 AM, Mark Williams <markwillimas@gmail.com> = wrote:

I= am new to Postgre. Migrating from MySQL.

&= nbsp;

I= am trying to connect via SSL to a PostgreSQL using FireDac in Delphi. I = have followed the instructions at the following site: https://www.howtoforge.com/postgresql-ssl-certificates= = to create my self-certified certificates and configure the config = files.

&= nbsp;

<= span = style=3D'font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729'>I= have coped the specified files to the client machine and installed the = root.crt certificate.

V= ia FireDAC's connection params I have specified the = following:

Params.values[SSL_ca']:=3DsslCertsPath+'<=
span class=3Dm-1438415984718051057m4917588911217483979pln>root.crt';
Params.values['SSL_cert']:=3DsslCertsPath+'<= span class=3Dm-1438415984718051057m4917588911217483979pln>postgresql.crt.';Params.values['SSL_key']:=3DsslCertsPath+'<= span class=3Dm-1438415984718051057m4917588911217483979pln>postgresql.key';

&= nbsp;

<= span = style=3D'font-size:11.5pt;font-family:"Arial",sans-serif;color:#242729'>I= am getting a connection error re invalid client certificate. =

I= have used OpenSSL to verify against the root.crt and postgresql.crt =  and this confirms the certificate is ok.

Mark

 <= /o:p>

__

 <= /o:p>

 <= /o:p>

 

------=_NextPart_000_03D8_01D433CE.30E2B370--