File tree 3 files changed +39
-2
lines changed
test/integration/connection
3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ you spot any mistakes.
16
16
* Remove console.warn from PoolCluster #744
17
17
* Fix ` pool.end ` to handle queued connections #797
18
18
* Fix ` pool.releaseConnection ` to keep connection queue flowing #797
19
+ * Fix SSL handshake error to be catchable #800
19
20
20
21
## v2.1.1 (2014-03-13)
21
22
Original file line number Diff line number Diff line change @@ -35,8 +35,16 @@ Handshake.prototype['HandshakeInitializationPacket'] = function(packet) {
35
35
var serverSSLSupport = packet . serverCapabilities1 & ClientConstants . CLIENT_SSL ;
36
36
37
37
if ( this . _config . ssl ) {
38
- if ( ! serverSSLSupport )
39
- throw new Error ( 'Server does not support secure connnection' ) ;
38
+ if ( ! serverSSLSupport ) {
39
+ var err = new Error ( 'Server does not support secure connnection' ) ;
40
+
41
+ err . code = 'HANDSHAKE_NO_SSL_SUPPORT' ;
42
+ err . fatal = true ;
43
+
44
+ this . end ( err ) ;
45
+ return ;
46
+ }
47
+
40
48
this . _config . clientFlags |= ClientConstants . CLIENT_SSL ;
41
49
this . emit ( 'packet' , new Packets . SSLRequestPacket ( {
42
50
clientFlags : this . _config . clientFlags ,
Original file line number Diff line number Diff line change
1
+ var assert = require ( 'assert' ) ;
2
+ var common = require ( '../../common' ) ;
3
+ var connection = common . createConnection ( {
4
+ port : common . fakeServerPort ,
5
+ ssl : 'Amazon RDS'
6
+ } ) ;
7
+
8
+ var server = common . createFakeServer ( ) ;
9
+
10
+ var connectErr ;
11
+ server . listen ( common . fakeServerPort , function ( err ) {
12
+ if ( err ) throw err ;
13
+
14
+ connection . connect ( function ( err ) {
15
+ connectErr = err ;
16
+ server . destroy ( ) ;
17
+ } ) ;
18
+ } ) ;
19
+
20
+ server . on ( 'connection' , function ( incomingConnection ) {
21
+ incomingConnection . handshake ( ) ;
22
+ } ) ;
23
+
24
+ process . on ( 'exit' , function ( ) {
25
+ assert . ok ( connectErr ) ;
26
+ assert . equal ( connectErr . code , 'HANDSHAKE_NO_SSL_SUPPORT' ) ;
27
+ assert . ok ( connectErr . fatal ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments