Skip to content
This repository
Browse code

Emit a 'secure' event on a Connection when TLS negotiation has comple…

…ted successfully.
  • Loading branch information...
commit 57e202c93c0f171912a9b7e650f2a77a02a85a9d 1 parent 295718f
Mike D Pilsbury authored July 16, 2012
1  src/connection.coffee
@@ -388,6 +388,7 @@ class Connection extends EventEmitter
388 388
       @debug.log("TLS negotiated (#{cipher.name}, #{cipher.version})")
389 389
       #console.log @securePair.cleartext.getPeerCertificate()
390 390
 
  391
+      @emit('secure', @securePair.cleartext)
391 392
       @dispatchEvent('tlsNegotiated')
392 393
     )
393 394
 
8  test/integration/connection-test.coffee
@@ -154,7 +154,7 @@ exports.connectByInstanceName = (test) ->
154 154
 
155 155
 
156 156
 exports.encrypt = (test) ->
157  
-  test.expect(2)
  157
+  test.expect(5)
158 158
 
159 159
   config = getConfig()
160 160
   config.options.encrypt = true
@@ -175,6 +175,12 @@ exports.encrypt = (test) ->
175 175
     test.strictEqual(database, config.options.database)
176 176
   )
177 177
 
  178
+  connection.on('secure', (cleartext) ->
  179
+    test.ok(cleartext)
  180
+    test.ok(cleartext.getCipher())
  181
+    test.ok(cleartext.getPeerCertificate())
  182
+  )
  183
+
178 184
   connection.on('infoMessage', (info) ->
179 185
     #console.log("#{info.number} : #{info.message}")
180 186
   )

0 notes on commit 57e202c

Please sign in to comment.
Something went wrong with that request. Please try again.