File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ var common = require ( '../common' ) ;
2
+ var assert = require ( 'assert' ) ;
3
+
4
+ if ( ! common . hasCrypto ) {
5
+ console . log ( '1..0 # Skipped: missing crypto' ) ;
6
+ process . exit ( ) ;
7
+ }
8
+
9
+ var https = require ( 'https' ) ;
10
+ var fs = require ( 'fs' ) ;
11
+
12
+ var options = {
13
+ key : fs . readFileSync ( common . fixturesDir + '/keys/agent1-key.pem' ) ,
14
+ cert : fs . readFileSync ( common . fixturesDir + '/keys/agent1-cert.pem' ) ,
15
+ ca : fs . readFileSync ( common . fixturesDir + '/keys/ca1-cert.pem' )
16
+ } ;
17
+
18
+
19
+ var server = https . Server ( options , function ( req , res ) {
20
+ res . writeHead ( 200 ) ;
21
+ res . end ( 'hello world\n' ) ;
22
+ } ) ;
23
+
24
+
25
+ server . listen ( common . PORT , function ( ) {
26
+ https . get ( {
27
+ path : '/' ,
28
+ port : common . PORT ,
29
+ rejectUnauthorized : true ,
30
+ servername : 'agent1' ,
31
+ ca : options . ca
32
+ } , function ( res ) {
33
+ res . resume ( ) ;
34
+ console . log ( res . statusCode ) ;
35
+ server . close ( ) ;
36
+ } ) . on ( 'error' , function ( e ) {
37
+ console . log ( e . message ) ;
38
+ process . exit ( 1 ) ;
39
+ } ) ;
40
+ } ) ;
You can’t perform that action at this time.
0 commit comments