Browse files

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

…ted successfully.
  • Loading branch information...
1 parent 295718f commit 57e202c93c0f171912a9b7e650f2a77a02a85a9d @pekim pekim committed Jul 16, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −0 src/connection.coffee
  2. +7 −1 test/integration/connection-test.coffee
View
1 src/connection.coffee
@@ -388,6 +388,7 @@ class Connection extends EventEmitter
@debug.log("TLS negotiated (#{cipher.name}, #{cipher.version})")
#console.log @securePair.cleartext.getPeerCertificate()
+ @emit('secure', @securePair.cleartext)
@dispatchEvent('tlsNegotiated')
)
View
8 test/integration/connection-test.coffee
@@ -154,7 +154,7 @@ exports.connectByInstanceName = (test) ->
exports.encrypt = (test) ->
- test.expect(2)
+ test.expect(5)
config = getConfig()
config.options.encrypt = true
@@ -175,6 +175,12 @@ exports.encrypt = (test) ->
test.strictEqual(database, config.options.database)
)
+ connection.on('secure', (cleartext) ->
+ test.ok(cleartext)
+ test.ok(cleartext.getCipher())
+ test.ok(cleartext.getPeerCertificate())
+ )
+
connection.on('infoMessage', (info) ->
#console.log("#{info.number} : #{info.message}")
)

0 comments on commit 57e202c

Please sign in to comment.