payara / Payara

Payara Server is an open source middleware platform that supports reliable and secure deployments of Java EE (Jakarta EE) and MicroProfile applications in any environment: on premise, in the cloud or hybrid.
http://www.payara.fish
Other
882 stars 306 forks source link

Strange problem with Payara/Glassfish and MongoDB-Atlas #1204

Closed ulrichcech closed 7 years ago

ulrichcech commented 7 years ago

Description


If I want to connect to the cloud-solution of MongoDB (MongoDB-Atlas), then I get the exception (see below). In a normal JUnit-test, this code works perfect. And even if executed in Wildfly, this works as expected, but not in Payara/Glassfish (tested with Glassfish 4.1, Payara 163, 164).

I had the ROOT CAs in mind, because if you debug it with Payara and Wildfly, you see, that the SSLFactory in Wildfly has 93 certificates, Payara only 76... and the cacerts-file of the JDK also has exactly 93 entries, so I think, Wildfly uses the JDK-cacerts file, where Payara usses its own in /domain/cacerts.jks file. I have exported every certificate from JDK-cacerts and imported it to Payara-cacerts-file, at the end I had 103 certificates in Payara-Cacerts-file, but the exception still occurred.

I use JDK 1.8.0_77, Mac OS Yosemite and tested with Glassfish 4.1, Payara 163/164, Wildfly 10.

An example project can be found here: https://github.com/UlrichCech/payara-mongoatlas

Expected Outcome

it should work ;-)

Current Outcome

[2016-11-24T22:12:28.948+0100] [Payara 4.1] [INFO] [] [org.mongodb.driver.cluster] [tid: _ThreadID=94 _ThreadName=cluster-ClusterId{value='583757b51ef89d3c41b6050f', description='null'}-test-shard-00-01-jgt7z.mongodb.net:27017] [timeMillis: 1480021948948] [levelValue: 800] [[ Exception in monitor thread while connecting to server test-shard-00-01-jgt7z.mongodb.net:27017 com.mongodb.MongoSocketReadException: Exception receiving message at com.mongodb.connection.InternalStreamConnection.translateReadException(InternalStreamConnection.java:481) at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:226) at com.mongodb.connection.CommandHelper.receiveReply(CommandHelper.java:134) at com.mongodb.connection.CommandHelper.receiveCommandResult(CommandHelper.java:121) at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32) at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:83) at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:43) at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:116) at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:116) at java.lang.Thread.run(Thread.java:745) Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:209) at java.net.SocketInputStream.read(SocketInputStream.java:141) at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) at sun.security.ssl.InputRecord.read(InputRecord.java:503) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973) at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:930) at sun.security.ssl.AppInputStream.read(AppInputStream.java:105) at com.mongodb.connection.SocketStream.read(SocketStream.java:85) at com.mongodb.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:492) at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:222) ... 8 more ]]

pdudits commented 7 years ago

Try asadmin delete-jvm-options "-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as", that removes default outgoing client certificate sent out by SSL factory.

This startup option burned me so many times already, I think it should be removed from default configuration.

ulrichcech commented 7 years ago

Man, you are the MASTER!!! Great, it works with this option, thank you very much!

mikecroft commented 7 years ago

Thanks @pdudits!

We've got an internal task - PAYARA-1225 - to enhance the payaradomain further, so I've added this to the list of things we should change.