@@ -17,7 +17,7 @@ Object.defineProperty(gen, 'port', {
17
17
} ) ;
18
18
19
19
describe ( 'lib/http-proxy.js' , function ( ) {
20
- describe ( '#createProxyServer using HTTPS ' , function ( ) {
20
+ describe ( 'HTTPS #createProxyServer' , function ( ) {
21
21
describe ( 'HTTPS to HTTP' , function ( ) {
22
22
it ( 'should proxy the request en send back the response' , function ( done ) {
23
23
var ports = { source : gen . port , proxy : gen . port } ;
@@ -79,6 +79,8 @@ describe('lib/http-proxy.js', function() {
79
79
80
80
var proxy = httpProxy . createProxyServer ( {
81
81
target : 'https://127.0.0.1:' + ports . source ,
82
+ // Allow to use SSL self signed
83
+ secure : false
82
84
} ) . listen ( ports . proxy ) ;
83
85
84
86
http . request ( {
@@ -100,5 +102,33 @@ describe('lib/http-proxy.js', function() {
100
102
} ) . end ( ) ;
101
103
} )
102
104
} )
105
+ describe ( 'HTTPS not allow SSL self signed' , function ( ) {
106
+ it ( 'should fail with error' , function ( done ) {
107
+ var ports = { source : gen . port , proxy : gen . port } ;
108
+ var source = https . createServer ( {
109
+ key : fs . readFileSync ( path . join ( __dirname , 'fixtures' , 'agent2-key.pem' ) ) ,
110
+ cert : fs . readFileSync ( path . join ( __dirname , 'fixtures' , 'agent2-cert.pem' ) ) ,
111
+ } ) . listen ( ports . source ) ;
112
+
113
+ var proxy = httpProxy . createProxyServer ( {
114
+ target : 'https://127.0.0.1:' + ports . source ,
115
+ secure : true
116
+ } ) ;
117
+
118
+ proxy . listen ( ports . proxy ) ;
119
+
120
+ proxy . on ( 'error' , function ( err , req , res ) {
121
+ expect ( err ) . to . be . an ( Error ) ;
122
+ expect ( err . toString ( ) ) . to . be ( 'Error: DEPTH_ZERO_SELF_SIGNED_CERT' )
123
+ done ( ) ;
124
+ } )
125
+
126
+ http . request ( {
127
+ hostname : '127.0.0.1' ,
128
+ port : ports . proxy ,
129
+ method : 'GET'
130
+ } ) . end ( ) ;
131
+ } )
132
+ } )
103
133
} ) ;
104
134
} ) ;
0 commit comments