Adding SSL support, release 0.2.3
This commit is contained in:
parent
9fc5d64ceb
commit
bc2fbe14e3
15
README.md
15
README.md
|
@ -5,7 +5,6 @@ A port of the EventStore .Net ClientAPI to Node.js
|
||||||
|
|
||||||
### Missing features:
|
### Missing features:
|
||||||
|
|
||||||
- Ssl connection
|
|
||||||
- Set system settings
|
- Set system settings
|
||||||
|
|
||||||
### Areas to improve
|
### Areas to improve
|
||||||
|
@ -26,9 +25,9 @@ Install using `npm install node-eventstore-client`
|
||||||
- Node.js >= 4.0
|
- Node.js >= 4.0
|
||||||
- Modules: [long](https://www.npmjs.org/package/long), [protobufjs](https://www.npmjs.org/package/protobufjs), [uuid](https://www.npmjs.org/package/uuid) (installed via `npm install`)
|
- Modules: [long](https://www.npmjs.org/package/long), [protobufjs](https://www.npmjs.org/package/protobufjs), [uuid](https://www.npmjs.org/package/uuid) (installed via `npm install`)
|
||||||
|
|
||||||
### Install & run an Eventstore on localhost
|
### Install and run an Eventstore on localhost
|
||||||
|
|
||||||
See https://eventstore.org/docs/introduction/4.0.2/
|
See https://eventstore.org/docs/introduction/4.1.0/
|
||||||
|
|
||||||
*Note: If you are using a version of EventStore prior to 3.9.4, you need to use version 0.1.x of this package `npm install node-eventstore-client@^0.1`.*
|
*Note: If you are using a version of EventStore prior to 3.9.4, you need to use version 0.1.x of this package `npm install node-eventstore-client@^0.1`.*
|
||||||
|
|
||||||
|
@ -115,7 +114,15 @@ To generate a test event, open a separate console and run:
|
||||||
|
|
||||||
To run the tests it is recommended that you use an in-memory instance of the eventstore so you don't pollute your dev instance.
|
To run the tests it is recommended that you use an in-memory instance of the eventstore so you don't pollute your dev instance.
|
||||||
|
|
||||||
EventStore.ClusterNode.exe --run-projections=all --memdb
|
EventStore.ClusterNode.exe --run-projections=all --memdb –certificate-file=yourcert.pfx
|
||||||
|
or
|
||||||
|
./run-node.sh --run-projections=all --memdb –certificate-file=yourcert.p12
|
||||||
|
|
||||||
|
For SSL setup see:
|
||||||
|
|
||||||
|
https://eventstore.org/docs/server/setting_up_ssl/
|
||||||
|
or
|
||||||
|
https://eventstore.org/docs/server/setting_up_ssl_linux/
|
||||||
|
|
||||||
To execute the tests suites simply run
|
To execute the tests suites simply run
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "node-eventstore-client",
|
"name": "node-eventstore-client",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"description": "A port of the EventStore .Net ClientAPI to Node.js",
|
"description": "A port of the EventStore .Net ClientAPI to Node.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var net = require('net');
|
var net = require('net');
|
||||||
|
var tls = require('tls');
|
||||||
var createBufferSegment = require('../../common/bufferSegment');
|
var createBufferSegment = require('../../common/bufferSegment');
|
||||||
|
|
||||||
const MaxSendPacketSize = 64 * 1024;
|
const MaxSendPacketSize = 64 * 1024;
|
||||||
|
@ -136,11 +137,16 @@ TcpConnection.prototype._closeInternal = function(err, reason) {
|
||||||
};
|
};
|
||||||
|
|
||||||
TcpConnection.createConnectingConnection = function(
|
TcpConnection.createConnectingConnection = function(
|
||||||
log, connectionId, remoteEndPoint, connectionTimeout,
|
log, connectionId, remoteEndPoint, ssl, targetHost, validateServer,
|
||||||
onConnectionEstablished, onConnectionFailed, onConnectionClosed
|
connectionTimeout, onConnectionEstablished, onConnectionFailed, onConnectionClosed
|
||||||
) {
|
) {
|
||||||
var connection = new TcpConnection(log, connectionId, remoteEndPoint, onConnectionClosed);
|
var connection = new TcpConnection(log, connectionId, remoteEndPoint, onConnectionClosed);
|
||||||
var socket = net.connect(remoteEndPoint.port, remoteEndPoint.host);
|
var provider = ssl ? tls : net;
|
||||||
|
var options = {
|
||||||
|
servername: targetHost,
|
||||||
|
rejectUnauthorized: validateServer
|
||||||
|
};
|
||||||
|
var socket = provider.connect(remoteEndPoint.port, remoteEndPoint.host, options);
|
||||||
function onError(err) {
|
function onError(err) {
|
||||||
if (onConnectionFailed)
|
if (onConnectionFailed)
|
||||||
onConnectionFailed(connection, err);
|
onConnectionFailed(connection, err);
|
||||||
|
|
|
@ -38,15 +38,14 @@ function TcpPackageConnection(
|
||||||
this._framer = new LengthPrefixMessageFramer();
|
this._framer = new LengthPrefixMessageFramer();
|
||||||
this._framer.registerMessageArrivedCallback(this._incomingMessageArrived.bind(this));
|
this._framer.registerMessageArrivedCallback(this._incomingMessageArrived.bind(this));
|
||||||
|
|
||||||
//TODO ssl
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this._connection = TcpConnection.createConnectingConnection(
|
this._connection = TcpConnection.createConnectingConnection(
|
||||||
log,
|
log,
|
||||||
connectionId,
|
connectionId,
|
||||||
remoteEndPoint,
|
remoteEndPoint,
|
||||||
//ssl,
|
ssl,
|
||||||
//targetHost,
|
targetHost,
|
||||||
//validateServer,
|
validateServer,
|
||||||
timeout,
|
timeout,
|
||||||
function(tcpConnection) {
|
function(tcpConnection) {
|
||||||
log.debug("TcpPackageConnection: connected to [%j, L%j, %s].", tcpConnection.remoteEndPoint, tcpConnection.localEndPoint, connectionId);
|
log.debug("TcpPackageConnection: connected to [%j, L%j, %s].", tcpConnection.remoteEndPoint, tcpConnection.localEndPoint, connectionId);
|
||||||
|
|
|
@ -72,7 +72,24 @@ module.exports = {
|
||||||
if (err) return test.done(err);
|
if (err) return test.done(err);
|
||||||
test.done();
|
test.done();
|
||||||
}
|
}
|
||||||
}*/
|
}*/,
|
||||||
|
'Connect to secure tcp endpoint': function(test) {
|
||||||
|
var conn = client.createConnection({
|
||||||
|
useSslConnection: true,
|
||||||
|
targetHost: 'localhost',
|
||||||
|
validateServer: false
|
||||||
|
}, 'tcp://localhost:1115');
|
||||||
|
conn.on('error', function (err) {
|
||||||
|
test.done(err);
|
||||||
|
});
|
||||||
|
conn.connect()
|
||||||
|
.catch(function (err) {
|
||||||
|
test.done(err);
|
||||||
|
});
|
||||||
|
conn.on('connected', function () {
|
||||||
|
test.done();
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
testBase.init(module.exports, false);
|
testBase.init(module.exports, false);
|
Loading…
Reference in New Issue
Block a user