Skip to content

Commit bed8ff1

Browse files
authored
NODEJS-647: Log negotiated SSL/TLS versions when using encrypted connections
1 parent 2ac2798 commit bed8ff1

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lib/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class Connection extends events.EventEmitter {
188188
}
189189

190190
this.netClient = tls.connect(this.port, this.address, sslOptions, function tlsConnectCallback() {
191-
self.log('verbose', `Secure socket connected to ${self.endpointFriendlyName}`);
191+
self.log('verbose', `Secure socket connected to ${self.endpointFriendlyName} with protocol ${self.netClient.getProtocol()}`);
192192
self.bindSocketListeners();
193193
self.startup(callback);
194194
});

lib/datastax/cloud/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class CloudOptions {
6363
} else {
6464
this.serviceUrl = clientOptions.cloud.endpoint;
6565
}
66+
// Include a log emitter to enable logging within the cloud connection logic
67+
this.logEmitter = clientOptions.logEmitter;
6668

6769
this.contactPoints = null;
6870
this.localDataCenter = null;
@@ -157,6 +159,8 @@ function getMetadataServiceInfo(cloudOptions, callback) {
157159
const req = https.get(requestOptions, res => {
158160
let data = '';
159161

162+
utils.log('verbose', `Connected to metadata service with SSL/TLS protocol ${res.socket.getProtocol()}`, {}, cloudOptions);
163+
160164
res
161165
.on('data', chunk => data += chunk.toString())
162166
.on('end', () => {

lib/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ function fixStack(stackTrace, error) {
126126
* @param {String} info
127127
* @param [furtherInfo]
128128
*/
129-
function log(type, info, furtherInfo) {
129+
function log(type, info, furtherInfo, options) {
130130
if (!this.logEmitter) {
131-
if (!this.options || !this.options.logEmitter) {
131+
const effectiveOptions = options || this.options;
132+
if (!effectiveOptions || !effectiveOptions.logEmitter) {
132133
throw new Error('Log emitter not defined');
133134
}
134-
this.logEmitter = this.options.logEmitter;
135+
this.logEmitter = effectiveOptions.logEmitter;
135136
}
136137
this.logEmitter('log', type, this.constructor.name, info, furtherInfo || '');
137138
}

0 commit comments

Comments
 (0)