@@ -6,30 +6,27 @@ const fs = require('fs');
66const port = 8000 ;
77
88const options = {
9- key : fs . readFileSync ( 'certs/server/server.key' ) ,
10- cert : fs . readFileSync ( 'certs/server/server.crt' ) ,
11- ca : fs . readFileSync ( 'certs/ca/ca.crt' ) , // authority chain for the clients
12- requestCert : true , // ask for a client cert
13- //rejectUnauthorized: false, // act on unauthorized clients at the app level
9+ key : fs . readFileSync ( 'certs/server/server.key' ) ,
10+ cert : fs . readFileSync ( 'certs/server/server.crt' ) ,
11+ ca : fs . readFileSync ( 'certs/ca/ca.crt' ) , // authority chain for the clients
12+ requestCert : true , // ask for a client cert
13+ //rejectUnauthorized: false, // act on unauthorized clients at the app level
1414} ;
1515
16- var server = tls . createServer ( options , ( socket ) => {
16+ const server = tls . createServer ( options , ( socket ) => {
1717 socket . write ( 'welcome!\n' ) ;
1818 socket . setEncoding ( 'utf8' ) ;
1919 socket . pipe ( socket ) ;
2020} )
21+ . on ( 'connection' , ( ) => {
22+ console . log ( 'insecure connection' ) ;
23+ } )
2124
22- . on ( 'connection' , function ( c )
23- {
24- console . log ( 'insecure connection' ) ;
25- } )
26-
27- . on ( 'secureConnection' , function ( c )
28- {
29- // c.authorized will be true if the client cert presented validates with our CA
30- console . log ( 'secure connection; client authorized: ' , c . authorized ) ;
31- } )
25+ . on ( 'secureConnection' , ( socket ) => {
26+ // c.authorized will be true if the client cert presented validates with our CA
27+ console . log ( 'secure connection; client authorized: ' , socket . authorized ) ;
28+ } )
3229
33- . listen ( port , function ( ) {
34- console . log ( 'server listening on port ' + port + '\n' ) ;
35- } ) ;
30+ . listen ( port , ( ) => {
31+ console . log ( 'server listening on port ' + port + '\n' ) ;
32+ } ) ;
0 commit comments