pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Certficates
6+ messages / 4 participants
[nested] [flat]

* Certficates
@ 2020-08-10 17:53  Shankar Bhaskaran <mailshankarb@gmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Shankar Bhaskaran @ 2020-08-10 17:53 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi All,

This is a very basic question . i have to import the server.crt on the
client side java trustore to connect using jdbc to postgres server secured
by ssl.
But when i try psql from same machine , it shows the connection as
encrypted . How does psql import the server certificate?

 psql "postgresql://$POSTGRES_HOST:$PG_PORT/postgres" -U postgres
psql (9.6.18)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384,
bits: 256, compression: off)
Type "help" for help.


Regards,
Shankar

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Certficates
@ 2020-08-10 18:10  Martin Gainty <mgainty@hotmail.com>
  parent: Shankar Bhaskaran <mailshankarb@gmail.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Martin Gainty @ 2020-08-10 18:10 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

cant you use keytool ?
assume server certificate is called server.crt
assume truststore file is called server.truststore.jks

cd %JRE_HOME%/lib/security
keytool -import -alias %ALIAS% -file server.crt -keystore server.truststore.jks

m.
________________________________
From: Shankar Bhaskaran <mailshankarb@gmail.com>
Sent: Monday, August 10, 2020 1:53 PM
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Certficates

Hi All,

This is a very basic question . i have to import the server.crt on the client side java trustore to connect using jdbc to postgres server secured by ssl.
But when i try psql from same machine , it shows the connection as encrypted . How does psql import the server certificate?

 psql "postgresql://$POSTGRES_HOST:$PG_PORT/postgres" -U postgres
psql (9.6.18)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.


Regards,
Shankar

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Certficates
@ 2020-08-10 20:08  David G. Johnston <david.g.johnston@gmail.com>
  parent: Shankar Bhaskaran <mailshankarb@gmail.com>
  1 sibling, 1 reply; 6+ messages in thread

From: David G. Johnston @ 2020-08-10 20:08 UTC (permalink / raw)
  To: Shankar Bhaskaran <mailshankarb@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

On Mon, Aug 10, 2020 at 10:54 AM Shankar Bhaskaran <mailshankarb@gmail.com>
wrote:

> How does psql import the server certificate?
>

See:

https://www.postgresql.org/docs/12/libpq-envars.html

Namely the "PGSSL*" prefixed environment variables.

It works by default because both the server and client are usually
installed from the same source and the same default certificate files are
provided to each.

David J.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Certficates
@ 2020-08-10 20:10  David G. Johnston <david.g.johnston@gmail.com>
  parent: Martin Gainty <mgainty@hotmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: David G. Johnston @ 2020-08-10 20:10 UTC (permalink / raw)
  To: Martin Gainty <mgainty@hotmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

The convention on these lists is to inline or bottom-post.

On Mon, Aug 10, 2020 at 11:11 AM Martin Gainty <mgainty@hotmail.com> wrote:

> cant you use keytool ?
>

That wasn't the question, the OP already indicated they can do this
successfully in JDBC.

David J.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Certficates
@ 2020-08-10 20:15  Tom Lane <tgl@sss.pgh.pa.us>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2020-08-10 20:15 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Shankar Bhaskaran <mailshankarb@gmail.com>; pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Aug 10, 2020 at 10:54 AM Shankar Bhaskaran <mailshankarb@gmail.com>
> wrote:
>> How does psql import the server certificate?

> It works by default because both the server and client are usually
> installed from the same source and the same default certificate files are
> provided to each.

Actually I suspect the answer is "it works because the default behavior
is to just encrypt the connection, not to try to verify the server
certificate".  If you want it to fail when it doesn't recognize the server
cert, you need sslmode=verify-ca or sslosslmode=verify-full in your
connection string.  See sslmode here:

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Certficates
@ 2020-08-11 16:26  Shankar Bhaskaran <mailshankarb@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Shankar Bhaskaran @ 2020-08-11 16:26 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi All ,

Thank you for all the replies , I think even if psql does not verify the
certificate , it still has to import it. I guess like David mentioned it
might have default certificates in the client and server.

Regards,
Shankar

On Tue, Aug 11, 2020 at 1:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "David G. Johnston" <david.g.johnston@gmail.com> writes:
> > On Mon, Aug 10, 2020 at 10:54 AM Shankar Bhaskaran <
> mailshankarb@gmail.com>
> > wrote:
> >> How does psql import the server certificate?
>
> > It works by default because both the server and client are usually
> > installed from the same source and the same default certificate files are
> > provided to each.
>
> Actually I suspect the answer is "it works because the default behavior
> is to just encrypt the connection, not to try to verify the server
> certificate".  If you want it to fail when it doesn't recognize the server
> cert, you need sslmode=verify-ca or sslosslmode=verify-full in your
> connection string.  See sslmode here:
>
>
> https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2020-08-11 16:26 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10 17:53 Certficates Shankar Bhaskaran <mailshankarb@gmail.com>
2020-08-10 18:10 ` Martin Gainty <mgainty@hotmail.com>
2020-08-10 20:10   ` David G. Johnston <david.g.johnston@gmail.com>
2020-08-10 20:08 ` David G. Johnston <david.g.johnston@gmail.com>
2020-08-10 20:15   ` Tom Lane <tgl@sss.pgh.pa.us>
2020-08-11 16:26     ` Shankar Bhaskaran <mailshankarb@gmail.com>

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