@ -1,5 +1,5 @@
'use strict' ;
var common = require ( '../common' ) ;
const common = require ( '../common' ) ;
if ( ! process . features . tls_ocsp ) {
common . skip ( 'node compiled without OpenSSL or ' +
@ -15,33 +15,33 @@ if (!common.hasCrypto) {
common . skip ( 'missing crypto' ) ;
return ;
}
var tls = require ( 'tls' ) ;
const tls = require ( 'tls' ) ;
var assert = require ( 'assert' ) ;
var fs = require ( 'fs' ) ;
var join = require ( 'path' ) . join ;
const assert = require ( 'assert' ) ;
const fs = require ( 'fs' ) ;
const join = require ( 'path' ) . join ;
const SSL_OP_NO_TICKET = require ( 'crypto' ) . constants . SSL_OP_NO_TICKET ;
var pfx = fs . readFileSync ( join ( common . fixturesDir , 'keys' , 'agent1-pfx.pem' ) ) ;
const pfx = fs . readFileSync ( join ( common . fixturesDir , 'keys' , 'agent1-pfx.pem' ) ) ;
function test ( testOptions , cb ) {
var keyFile = join ( common . fixturesDir , 'keys' , 'agent1-key.pem' ) ;
var certFile = join ( common . fixturesDir , 'keys' , 'agent1-cert.pem' ) ;
var caFile = join ( common . fixturesDir , 'keys' , 'ca1-cert.pem' ) ;
var key = fs . readFileSync ( keyFile ) ;
var cert = fs . readFileSync ( certFile ) ;
var ca = fs . readFileSync ( caFile ) ;
var options = {
const keyFile = join ( common . fixturesDir , 'keys' , 'agent1-key.pem' ) ;
const certFile = join ( common . fixturesDir , 'keys' , 'agent1-cert.pem' ) ;
const caFile = join ( common . fixturesDir , 'keys' , 'ca1-cert.pem' ) ;
const key = fs . readFileSync ( keyFile ) ;
const cert = fs . readFileSync ( certFile ) ;
const ca = fs . readFileSync ( caFile ) ;
const options = {
key : key ,
cert : cert ,
ca : [ ca ]
} ;
var requestCount = 0 ;
var clientSecure = 0 ;
var ocspCount = 0 ;
var ocspResponse ;
let requestCount = 0 ;
let clientSecure = 0 ;
let ocspCount = 0 ;
let ocspResponse ;
if ( testOptions . pfx ) {
delete options . key ;
@ -50,7 +50,7 @@ function test(testOptions, cb) {
options . passphrase = testOptions . passphrase ;
}
var server = tls . createServer ( options , function ( cleartext ) {
const server = tls . createServer ( options , function ( cleartext ) {
cleartext . on ( 'error' , function ( er ) {
// We're ok with getting ECONNRESET in this test, but it's
// timing-dependent, and thus unreliable. Any other errors
@ -73,7 +73,7 @@ function test(testOptions, cb) {
} , 100 ) ;
} ) ;
server . listen ( 0 , function ( ) {
var client = tls . connect ( {
const client = tls . connect ( {
port : this . address ( ) . port ,
requestOCSP : testOptions . ocsp !== false ,
secureOptions : testOptions . ocsp === false ?
@ -94,23 +94,23 @@ function test(testOptions, cb) {
process . on ( 'exit' , function ( ) {
if ( testOptions . ocsp === false ) {
assert . e qual( requestCount , clientSecure ) ;
assert . e qual( requestCount , 1 ) ;
assert . strictE qual( requestCount , clientSecure ) ;
assert . strictE qual( requestCount , 1 ) ;
return ;
}
if ( testOptions . response ) {
assert . e qual( ocspResponse . toString ( ) , testOptions . response ) ;
assert . strictE qual( ocspResponse . toString ( ) , testOptions . response ) ;
} else {
assert . ok ( ocspResponse === null ) ;
assert . strictEqual ( ocspResponse , null ) ;
}
assert . e qual( requestCount , testOptions . response ? 0 : 1 ) ;
assert . e qual( clientSecure , requestCount ) ;
assert . e qual( ocspCount , 1 ) ;
assert . strictE qual( requestCount , testOptions . response ? 0 : 1 ) ;
assert . strictE qual( clientSecure , requestCount ) ;
assert . strictE qual( ocspCount , 1 ) ;
} ) ;
}
var tests = [
const tests = [
{ response : false } ,
{ response : 'hello world' } ,
{ ocsp : false }