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 1g2Gao-000645-6f for pgsql-jdbc@arkaria.postgresql.org; Tue, 18 Sep 2018 14:03:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g2Gam-0001Od-Ko for pgsql-jdbc@arkaria.postgresql.org; Tue, 18 Sep 2018 14:03:04 +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 1g2Gam-0001OW-C5 for pgsql-jdbc@lists.postgresql.org; Tue, 18 Sep 2018 14:03:04 +0000 Received: from mail.sonicle.com ([62.173.161.2]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g2Gah-0000Ps-Mj for pgsql-jdbc@lists.postgresql.org; Tue, 18 Sep 2018 14:03:03 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.sonicle.com (Postfix) with ESMTP id 7AB1E633056; Tue, 18 Sep 2018 16:02:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sonicle.com; h= content-type:content-type:mime-version:subject:subject :references:in-reply-to:message-id:from:from:date:date:received :received; s=dkim; t=1537279378; x=1539093779; bh=5P8tw4hJ5yKskb nAJa9LI+abbZJakppkqf4jTfvzk8U=; b=hccBZ85VpJ10FiIuehu2xiV3FuVhr4 R0gPtkI0jFdhEHbS0mIlGyOhdO2anostEuoOxFs/iwRShfrhuuDZmrJDw1RC8H9Z 82Y/Np3//cZSquE14WawN3p8rEyOqUpI6ELN1BhtEqAeRl2QYw3ecyoQevWO4P4G opzBzQ+pAyzeg= Received: from www ([127.0.0.1]) by localhost (mail.sonicle.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1XhCSOFss0hb; Tue, 18 Sep 2018 16:02:58 +0200 (CEST) Received: from www (www [192.168.222.200]) by www with SMTP (SubEthaSMTP 3.1.7) id JM7SG7UZ; Tue, 18 Sep 2018 16:02:58 +0200 (CEST) Date: Tue, 18 Sep 2018 16:02:58 +0200 (CEST) From: Gabriele Bulfon To: Dave Cramer Cc: =?UTF-8?Q?Alexander_Kj=C3=A4ll?= , pgsql-jdbc@lists.postgresql.org Message-ID: <441859077.1912.1537279378378@www> In-Reply-To: References: <652759681.5047.1536841425886@www> <491225265.1372.1537176204835@www> <90731313-9cd6-c020-9270-c9ef5d380390@gmail.com> <1954323705.1855.1537278167094@www> Subject: Re: ssl connection issues MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_1910_197147258.1537279378377" Forwarded-From: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_1910_197147258.1537279378377 Content-Type: multipart/alternative; boundary="----=_Part_1911_1231231621.1537279378377" ------=_Part_1911_1231231621.1537279378377 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I used easy-rsa, same tools I use for OpenVPN. Just cloned the easy-rsa tools to a specific new folder configured for Post= gres and ran in sequence: =C2=A0 . ./vars ./clean-all ./build-ca ./build-dh ./build-key-server server =C2=A0 copied server.key, server.crt and ca.crt to my pgdata as server.key, server= .crt and root.crt , configured postgres.conf with the server cert names and= restarted postgres. =C2=A0 Then I built the client certificate with "./build-key client" speicifying t= he=C2=A0needed postgres user as dn. They all works great on both Navicat and ODBC. =C2=A0 Gabriele Sonicle S.r.l.=C2=A0 :=C2=A0 http://www.sonicle.com Music:=C2=A0 http://www.gabrielebulfon.com Quantum Mechanics :=C2=A0 http://www.cdbaby.com/cd/gabrielebulfon Da: Dave Cramer A: Gabriele Bulfon Cc: Alexander Kj=C3=A4ll pgsql-jdbc@lists.postgresql.org Data: 18 settembre 2018 15.53.20 CEST Oggetto: Re: ssl connection issues Hi Gabriele, =C2=A0 Can you share your entire setup? How you are creating the certs, etc ? =C2=A0 Dave Cramer davec@postgresintl.com www.postgresintl.com On Tue, 18 Sep 2018 at 09:42, Gabriele Bulfon gbulfon@sonicle.com wrote: I had a chance to clone the illumos zone to a separate server and upgrade p= ostgres to latest 10.5. The results are the same: =C2=A0 Postgres logs "could not accept SSL connection: ccs received early" =C2=A0 The Java code throws the exception: =C2=A0 Exception in thread "main" org.postgresql.util.PSQLException: SSL error: Re= ceived fatal alert: unexpected_message at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:42) at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactory= Impl.java:435) at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactor= yImpl.java:94) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(Connecti= onFactoryImpl.java:192) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.j= ava:49) at org.postgresql.jdbc.PgConnection. (PgConnection.java:195) at org.postgresql.Driver.makeConnection(Driver.java:454) at org.postgresql.Driver.connect(Driver.java:256) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at com.sonicle.aliseo.server.TestPostgresSSL.main(TestPostgresSSL.java:23) Caused by: javax.net.ssl.SSLException: Received fatal alert: unexpected_mes= sage at sun.security.ssl.Alerts.getSSLException(Alerts.java:208) at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.jav= a:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:40) ... 10 more set 18, 2018 3:35:15 PM org.postgresql.Driver connect BUONO: Connecting with URL: jdbc:postgresql://x.x.x.x:5432/dbname?ssl=3Dtru= e&loggerLevel=3DDEBUG&sslfactory=3Dorg.postgresql.ssl.LibPQFactory&sslmode= =3Drequire&sslkey=3DC:\Users\user\AppData\Roaming\postgresql\client.key&ssl= cert=3DC:\Users\user\AppData\Roaming\postgresql\client.crt&sslrootcert=3DC:= \Users\user\AppData\Roaming\postgresql\root.crt set 18, 2018 3:35:15 PM org.postgresql.jdbc.PgConnection BUONO: PostgreSQL JDBC Driver 42.2.5.jre7 set 18, 2018 3:35:15 PM org.postgresql.jdbc.PgConnection setDefaultFetchSiz= e BUONO: setDefaultFetchSize =3D 0 set 18, 2018 3:35:15 PM org.postgresql.jdbc.PgConnection setPrepareThreshol= d BUONO: setPrepareThreshold =3D 5 set 18, 2018 3:35:15 PM org.postgresql.core.v3.ConnectionFactoryImpl openCo= nnectionImpl BUONO: Trying to establish a protocol version 3 connection to x.x.x.x:5432 set 18, 2018 3:35:15 PM org.postgresql.ssl.MakeSSL convert BUONO: converting regular socket connection to ssl set 18, 2018 3:35:16 PM org.postgresql.Driver connect BUONO: Connection error: org.postgresql.util.PSQLException: SSL error: Received fatal alert: unexpec= ted_message at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:42) at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactory= Impl.java:435) at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactor= yImpl.java:94) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(Connecti= onFactoryImpl.java:192) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.j= ava:49) at org.postgresql.jdbc.PgConnection. (PgConnection.java:195) at org.postgresql.Driver.makeConnection(Driver.java:454) at org.postgresql.Driver.connect(Driver.java:256) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at com.sonicle.aliseo.server.TestPostgresSSL.main(TestPostgresSSL.java:23) Caused by: javax.net.ssl.SSLException: Received fatal alert: unexpected_mes= sage at sun.security.ssl.Alerts.getSSLException(Alerts.java:208) at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.jav= a:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:40) ... 10 more =C2=A0 Sonicle S.r.l.=C2=A0 :=C2=A0 http://www.sonicle.com Music:=C2=A0 http://www.gabrielebulfon.com Quantum Mechanics :=C2=A0 http://www.cdbaby.com/cd/gabrielebulfon Da: Dave Cramer pg@fastcrypt.com A: Alexander Kj=C3=A4ll alexander.kjall@gmail.com Cc: pgsql-jdbc@lists.postgresql.org Data: 17 settembre 2018 12.38.18 CEST Oggetto: Re: ssl connection issues =C2=A0 On Mon, 17 Sep 2018 at 06:10, Alexander Kj=C3=A4ll alexander.kjall@gmail.com wrote: Another avenue for debugging would be to get a free "real" certificate from https://letsencrypt.org/ and check if that works. That way you can see if it's something in your certificate creation process that causes trouble. //Alexander Kj=C3=A4ll On 17. sep. 2018 11:56, Mark Rotteveel wrote: On 2018-09-17 11:23, Gabriele Bulfon wrote: That may be a possibility, but given that I cannot upgrade at the moment, how can I check this and maybe change the required cipher to match? Debugging SSL problems is not really something I do regularly, but you may want to see if changing the settings in the java.security policy helps. Settings to try are: jdk.tls.disabledAlgorithms jdk.certpath.disabledAlgorithms For reference: Java 8 Update 31, disabled SSLv3: http://www.oracle.com/technetwork/java/javase/8u31-relnotes-2389094.html , Java 8 Update 51, disabled some cipher suites, and limitations for DH keys where added: http://www.oracle.com/technetwork/java/javase/8u51-relnotes-2587590.html , similar for Java 8 Update 60: http://www.oracle.com/technetwork/java/javase/8u60-relnotes-2620227.html Java 8 update 71 disabled MD5 hash validation of certificates Java 8 update 121 added restrictions on DSA keysize: http://www.oracle.com/technetwork/java/javase/8u121-relnotes-3315208.html Java 8 Update 141 disabled SHA-1 hashes for the certificate chain: http://www.oracle.com/technetwork/java/javase/8u141-relnotes-3720385.html Java 8 update 161 added limitations for DH keys, made some changes to certificate validation and disabled a number of cipher suites: http://www.oracle.com/technetwork/java/javase/8u161-relnotes-4021379.html Java 8 update 171 disabled some ciphersuites: http://www.oracle.com/technetwork/java/javase/8u171-relnotes-4308888.html Mark =C2=A0 =C2=A0 have a look at certdir in the source code. Setting up the ssl tests is not = particularly difficult. Perhaps getting our tests working first might shed = some light ?? =C2=A0 Dave Cramer davec@postgresintl.com www.postgresintl.com ------=_Part_1911_1231231621.1537279378377 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I used easy-rsa, same tools I use for OpenVPN.
Just c= loned the easy-rsa tools to a specific new folder configured for Postgres a= nd ran in sequence:
 =
. ./va= rs
./clean-all
./build-ca
./build-dh
./build-key-server= server
 =
copied= server.key, server.crt and ca.crt to my pgdata as server.key, server.crt a= nd root.crt , configured postgres.conf with the server cert names and resta= rted postgres.
 =
Then I= built the client certificate with "./build-key client" speicifying the= 0;needed postgres user as dn.
They a= ll works great on both Navicat and ODBC.
 =
Gabrie= le

Sonic= le S.r.l. : http://www.sonicle.com




Da: Dave Cramer <pg@fastcrypt= .com>
A: Gabriele Bulfon <gbulfon@sonicle.com&g= t;
Cc: Alexander Kjäll <alexander.kjall@gmail= .com>pgsql-jdbc@lists.postgresql.org
Data: 18 sett= embre 2018 15.53.20 CEST
Oggetto: Re: ssl connection = issues


Hi Gabriele,
 
Can you share your entire setup? How you are creating the certs, etc ?=
 

On Tue, 18 Sep 2018 at 09:42, Gabriele Bulfon <gbulfon@sonicle.com> wrote:
I had = a chance to clone the illumos zone to a separate server and upgrade postgre= s to latest 10.5.
The re= sults are the same:
 =
Postgr= es logs "could not accept SSL connection: ccs received early"
 =
The Ja= va code throws the exception:
 =
Except= ion in thread "main" org.postgresql.util.PSQLException: SSL error: Received= fatal alert: unexpected_message
at org.postgresql.ssl.MakeSSL.conver= t(MakeSSL.java:42)
at org.postgresql.core.v3.ConnectionFactoryImpl.en= ableSSL(ConnectionFactoryImpl.java:435)
at org.postgresql.core.v3.Con= nectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:94)
at org.p= ostgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactor= yImpl.java:192)
at org.postgresql.core.ConnectionFactory.openConnecti= on(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<= ;init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnect= ion(Driver.java:454)
at org.postgresql.Driver.connect(Driver.java:256= )
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at= com.sonicle.aliseo.server.TestPostgresSSL.main(TestPostgresSSL.java:23)Caused by: javax.net.ssl.SSLException: Received fatal alert: unexpected_= message
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208) at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at s= un.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023)
at s= un.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125)
at = sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1= 375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.j= ava:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketI= mpl.java:1387)
at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:40)=
... 10 more
set 18, 2018 3:35:15 PM org.postgresql.Driver conne= ct
BUONO: Connecting with URL: jdbc:postgresql://x.x.x.x:5432/dbname?s= sl=3Dtrue&loggerLevel=3DDEBUG&sslfactory=3Dorg.postgresql.ssl.LibPQ= Factory&sslmode=3Drequire&sslkey=3DC:\Users\user\AppData\Roaming\po= stgresql\client.key&sslcert=3DC:\Users\user\AppData\Roaming\postgresql\= client.crt&sslrootcert=3DC:\Users\user\AppData\Roaming\postgresql\root.= crt
set 18, 2018 3:35:15 PM org.postgresql.jdbc.PgConnection <init&= gt;
BUONO: PostgreSQL JDBC Driver 42.2.5.jre7
set 18, 2018 3:35:1= 5 PM org.postgresql.jdbc.PgConnection setDefaultFetchSize
BUONO: setDe= faultFetchSize =3D 0
set 18, 2018 3:35:15 PM org.postgresql.jdbc.PgCon= nection setPrepareThreshold
BUONO: setPrepareThreshold =3D 5
set = 18, 2018 3:35:15 PM org.postgresql.core.v3.ConnectionFactoryImpl openConnec= tionImpl
BUONO: Trying to establish a protocol version 3 connection to= x.x.x.x:5432
set 18= , 2018 3:35:15 PM org.postgresql.ssl.MakeSSL convert
BUONO: converting= regular socket connection to ssl
set 18, 2018 3:35:16 PM org.postgres= ql.Driver connect
BUONO: Connection error:
org.postgresql.util.P= SQLException: SSL error: Received fatal alert: unexpected_message
at = org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:42)
at org.postgresql= .core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:435) at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFa= ctoryImpl.java:94)
at org.postgresql.core.v3.ConnectionFactoryImpl.op= enConnectionImpl(ConnectionFactoryImpl.java:192)
at org.postgresql.co= re.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org= .postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at = org.postgresql.Driver.makeConnection(Driver.java:454)
at org.postgres= ql.Driver.connect(Driver.java:256)
at java.sql.DriverManager.getConne= ction(DriverManager.java:664)
at java.sql.DriverManager.getConnection= (DriverManager.java:247)
at com.sonicle.aliseo.server.TestPostgresSSL= .main(TestPostgresSSL.java:23)
Caused by: javax.net.ssl.SSLException: = Received fatal alert: unexpected_message
at sun.security.ssl.Alerts.g= etSSLException(Alerts.java:208)
at sun.security.ssl.Alerts.getSSLExce= ption(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SS= LSocketImpl.java:2023)
at sun.security.ssl.SSLSocketImpl.readRecord(S= SLSocketImpl.java:1125)
at sun.security.ssl.SSLSocketImpl.performInit= ialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketIm= pl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSoc= ketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.postgresql.ssl= .MakeSSL.convert(MakeSSL.java:40)
... 10 more
 =

=
Sonic= le S.r.l. : http://www.sonicle.com
Quant= um Mechanics : http://www.cdbaby.com/cd/gabrielebulfon<= /div>




Da: Dave Cramer <pg@fastcrypt.com>
A: Alexander Kjäll <alexander.kjall@gmail.com>
= Cc: pgsql-jdbc@lists.postgresql.org
Data: 17 s= ettembre 2018 12.38.18 CEST
Oggetto: Re: ssl connecti= on issues



 

On Mon, 17 Sep 2018 at 06:10, Alexander Kjäll <alexander.kjall= @gmail.com> wrote:
Another avenue for debugging would be = to get a free "real" certificate
from https://letsencrypt.org/ an= d check if that works.

That way you can see if it's something = in your certificate creation
process that causes trouble.

//Alexander Kjäll

On 17. sep. 2018 11:56, Mark Rotteve= el wrote:
> On 2018-09-17 11:23, Gabriele Bulfon wrote:
>= > That may be a possibility, but given that I cannot upgrade at the
>> moment, how can I check this and maybe change the required ciphe= r to
>> match?
>
> Debugging SSL problems is = not really something I do regularly, but you
> may want to see if= changing the settings in the java.security policy
> helps. Setti= ngs to try are:
>
> jdk.tls.disabledAlgorithms
>= jdk.certpath.disabledAlgorithms
>
> For reference:
= >
> Java 8 Update 31, disabled SSLv3:
> http://www.oracle.com/technetwork/java/j= avase/8u31-relnotes-2389094.html,
> Java 8 Update 51, disabled= some cipher suites, and limitations for DH
> keys where added: <= br /> > http://www.oracle= .com/technetwork/java/javase/8u51-relnotes-2587590.html,
> sim= ilar for Java 8 Update 60:
> http://www.oracle.com/technetwork/java/javase/8u60-relnotes-2620= 227.html
> Java 8 update 71 disabled MD5 hash validation of ce= rtificates
> Java 8 update 121 added restrictions on DSA keysize: =
> http://www.orac= le.com/technetwork/java/javase/8u121-relnotes-3315208.html
> J= ava 8 Update 141 disabled SHA-1 hashes for the certificate chain:
&g= t; http://www.oracle.com/te= chnetwork/java/javase/8u141-relnotes-3720385.html
> Java 8 upd= ate 161 added limitations for DH keys, made some changes to
> cer= tificate validation and disabled a number of cipher suites:
> http://www.oracle.com/technetw= ork/java/javase/8u161-relnotes-4021379.html
> Java 8 update 17= 1 disabled some ciphersuites:
> http://www.oracle.com/technetwork/java/javase/8u171-relnote= s-4308888.html
>
> Mark
>
 
 
have a look at certdir in the source code. Setting up the ssl tests is= not particularly difficult. Perhaps getting our tests working first might = shed some light ??
 
------=_Part_1911_1231231621.1537279378377-- ------=_Part_1910_197147258.1537279378377--