@ -1,30 +1,30 @@
'use strict' ;
'use strict' ;
var common = require ( '../common' ) ;
const common = require ( '../common' ) ;
var assert = require ( 'assert' ) ;
const assert = require ( 'assert' ) ;
if ( ! common . hasCrypto ) {
if ( ! common . hasCrypto ) {
common . skip ( 'missing crypto' ) ;
common . skip ( 'missing crypto' ) ;
return ;
return ;
}
}
var tls = require ( 'tls' ) ;
const tls = require ( 'tls' ) ;
var fs = require ( 'fs' ) ;
const fs = require ( 'fs' ) ;
var spawn = require ( 'child_process' ) . spawn ;
const spawn = require ( 'child_process' ) . spawn ;
if ( common . opensslCli === false ) {
if ( common . opensslCli === false ) {
common . skip ( 'node compiled without OpenSSL CLI.' ) ;
common . skip ( 'node compiled without OpenSSL CLI.' ) ;
return ;
return ;
}
}
var cert = fs . readFileSync ( common . fixturesDir + '/test_cert.pem' ) ;
const cert = fs . readFileSync ( common . fixturesDir + '/test_cert.pem' ) ;
var key = fs . readFileSync ( common . fixturesDir + '/test_key.pem' ) ;
const key = fs . readFileSync ( common . fixturesDir + '/test_key.pem' ) ;
var server = tls . createServer ( { cert : cert , key : key } , common . fail ) ;
const server = tls . createServer ( { cert : cert , key : key } , common . fail ) ;
var errors = [ ] ;
const errors = [ ] ;
var stderr = '' ;
let stderr = '' ;
server . listen ( 0 , '127.0.0.1' , function ( ) {
server . listen ( 0 , '127.0.0.1' , function ( ) {
var address = this . address ( ) . address + ':' + this . address ( ) . port ;
const address = this . address ( ) . address + ':' + this . address ( ) . port ;
var args = [ 's_client' ,
const args = [ 's_client' ,
'-ssl3' ,
'-ssl3' ,
'-connect' , address ] ;
'-connect' , address ] ;
@ -32,14 +32,14 @@ server.listen(0, '127.0.0.1', function() {
if ( common . isWindows )
if ( common . isWindows )
args . push ( '-no_rand_screen' ) ;
args . push ( '-no_rand_screen' ) ;
var client = spawn ( common . opensslCli , args , { stdio : 'pipe' } ) ;
const client = spawn ( common . opensslCli , args , { stdio : 'pipe' } ) ;
client . stdout . pipe ( process . stdout ) ;
client . stdout . pipe ( process . stdout ) ;
client . stderr . pipe ( process . stderr ) ;
client . stderr . pipe ( process . stderr ) ;
client . stderr . setEncoding ( 'utf8' ) ;
client . stderr . setEncoding ( 'utf8' ) ;
client . stderr . on ( 'data' , ( data ) => stderr += data ) ;
client . stderr . on ( 'data' , ( data ) => stderr += data ) ;
client . once ( 'exit' , common . mustCall ( function ( exitCode ) {
client . once ( 'exit' , common . mustCall ( function ( exitCode ) {
assert . e qual( exitCode , 1 ) ;
assert . strictE qual( exitCode , 1 ) ;
server . close ( ) ;
server . close ( ) ;
} ) ) ;
} ) ) ;
} ) ;
} ) ;
@ -50,7 +50,7 @@ process.on('exit', function() {
if ( /unknown option -ssl3/ . test ( stderr ) ) {
if ( /unknown option -ssl3/ . test ( stderr ) ) {
common . skip ( '`openssl s_client -ssl3` not supported.' ) ;
common . skip ( '`openssl s_client -ssl3` not supported.' ) ;
} else {
} else {
assert . e qual( errors . length , 1 ) ;
assert . strictE qual( errors . length , 1 ) ;
assert ( /:wrong version number/ . test ( errors [ 0 ] . message ) ) ;
assert ( /:wrong version number/ . test ( errors [ 0 ] . message ) ) ;
}
}
} ) ;
} ) ;