'use strict';

/**
 * Represents an https imposter
 * @module
 */

function createBaseServer (options) {
    const path = require('path'),
        fs = require('fs'),
        metadata = {
            key: options.key || fs.readFileSync(path.join(__dirname, '/cert/mb-key.pem'), 'utf8'),
            cert: options.cert || fs.readFileSync(path.join(__dirname, '/cert/mb-cert.pem'), 'utf8'),
            mutualAuth: Boolean(options.mutualAuth)
        },
        // client certs will not reject the request.  It does set the request.client.authorized variable
        // to false for all self-signed certs; use rejectUnauthorized: true and a ca: field set to an array
        // containing the client cert to see request.client.authorized = true
        config = {
            key: metadata.key,
            cert: metadata.cert,
            mutualAuth: metadata.cert,
            rejectUnauthorized: false
        },
        createNodeServer = () => require('https').createServer(config);

    if (options.ciphers) {
        metadata.ciphers = options.ciphers.toUpperCase();
        config.ciphers = options.ciphers.toUpperCase();
    }

    return { metadata, createNodeServer };
}

module.exports = require('../http/baseHttpServer')(createBaseServer);

@@ -433,16 +433,121 @@
 ualAuth)
+,%0A            rejectUnauthorized: options.rejectUnauthorized %7C%7C false,%0A            ca: options.ca %7C%7C null
 %0A       
@@ -949,36 +949,42 @@
 lAuth: metadata.
-cert
+mutualAuth
 ,%0A            re
@@ -1001,21 +1001,128 @@
 orized: 
-false
+metadata.rejectUnauthorized,%0A            ca: metadata.ca,%0A            requestCert: !!metadata.rejectUnauthorized
 %0A       

Add options to httpsServer to allow client certificate validation