orientechnologies / orientjs

The official fast, lightweight node.js client for OrientDB
http://orientdb.com
Other
326 stars 67 forks source link

Connect to server with binary protocol using ssl #433

Open fersm opened 4 years ago

fersm commented 4 years ago

Hi.

When performing connection tests using the binary protocol with and without ssl enabled using pooled sessions with OrientDBClient:

const client = await OrientDBClient.connect({ host: '12.0.0.1', port: '2424' // or port: '2434' for ssl }); const sessionsPool = await client.sessions({ name: 'demo', username: 'test', password: 'xxxxxxxxxxx' }); await sessionsPool.acquire().then( async session => { await session.select().from('Store').all().then( async stores => { console.log( stores ) } ) } )

Using port 2434 for SSL, the application cannot connect to the server and is frozen waiting for the connection (const client = await OrientDBClient.connect) without showing any error or failure. When I close the application, on the server side, the following appears in the log:

Error on client connection javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake at java.base/sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1313) at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152) at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1055) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:395) at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketImpl.java:709) at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:962) at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81) at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142) at java.base/java.io.DataOutputStream.flush(DataOutputStream.java:123) at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.flush(OChannelBinary.java:330) at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.config(ONetworkProtocolBinary.java:136) at com.orientechnologies.orient.server.network.OServerNetworkListener.run(OServerNetworkListener.java:218) Caused by: java.io.EOFException: SSL peer shut down incorrectly at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:167) at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:108) at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1144) ... 10 more

If I use ODatabase to connect either on port 2424 or 2434, there is no problem:

const db = new ODatabase({ host: '127.0.0.1', port: '2424', // or port: '2434' for ssl name: 'demo', username: 'test', password: 'xxxxxxxxxxx' }); db.select().from('Store').all().then( async stores => { console.log( stores ) } )

Are there any limitations when using OrientDBClient with SSL?

In advance thank you very much for the help.