function generateDomainCertificate(domains) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const domainPath = constants_1.getStableDomainPath(domains);
        mkdirp_1.sync(constants_1.pathForDomain(domainPath));
        debug(`Generating private key for ${domains}`);
        let domainKeyPath = constants_1.pathForDomain(domainPath, 'private-key.key');
        generateKey(domainKeyPath);
        debug(`Generating certificate signing request for ${domains}`);
        let csrFile = constants_1.pathForDomain(domainPath, `certificate-signing-request.csr`);
        constants_1.withDomainSigningRequestConfig(domains, (configpath) => {
            utils_1.openssl(['req', '-new', '-config', configpath, '-key', domainKeyPath, '-out', csrFile]);
        });
        debug(`Generating certificate for ${domains} from signing request and signing with root CA`);
        let domainCertPath = constants_1.pathForDomain(domainPath, `certificate.crt`);
        yield certificate_authority_1.withCertificateAuthorityCredentials(({ caKeyPath, caCertPath }) => {
            constants_1.withDomainCertificateConfig(domains, (domainCertConfigPath) => {
                utils_1.openssl(['ca', '-config', domainCertConfigPath, '-in', csrFile, '-out', domainCertPath, '-keyfile', caKeyPath, '-cert', caCertPath, '-days', '825', '-batch']);
            });
        });
    });
}
/**
 * Generate a domain certificate signed by the devcert root CA. Domain
 * certificates are cached in their own directories under
 * CONFIG_ROOT/domains/<domain>, and reused on subsequent requests. Because the
 * individual domain certificates are signed by the devcert root CA (which was
 * added to the OS/browser trust stores), they are trusted.
 */
Generate a domain certificate signed by the devcert root CA. Domain
certificates are cached in their own directories under
CONFIG_ROOT/domains/, and reused on subsequent requests. Because the
individual domain certificates are signed by the devcert root CA (which was
added to the OS/browser trust stores), they are trusted.
Generate a domain certificate signed by the devcert root CA . Domain certificates are cached in their own directories under CONFIG_ROOT / domains / and reused on subsequent requests . Because the individual domain certificates are signed by the devcert root CA ( which was added to the OS / browser trust stores ) they are trusted .
function generateDomainCertificate(domains) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const domainPath = constants_1.getStableDomainPath(domains);
        mkdirp_1.sync(constants_1.pathForDomain(domainPath));
        debug(`Generating private key for ${domains}`);
        let domainKeyPath = constants_1.pathForDomain(domainPath, 'private-key.key');
        generateKey(domainKeyPath);
        debug(`Generating certificate signing request for ${domains}`);
        let csrFile = constants_1.pathForDomain(domainPath, `certificate-signing-request.csr`);
        constants_1.withDomainSigningRequestConfig(domains, (configpath) => {
            utils_1.openssl(['req', '-new', '-config', configpath, '-key', domainKeyPath, '-out', csrFile]);
        });
        debug(`Generating certificate for ${domains} from signing request and signing with root CA`);
        let domainCertPath = constants_1.pathForDomain(domainPath, `certificate.crt`);
        yield certificate_authority_1.withCertificateAuthorityCredentials(({ caKeyPath, caCertPath }) => {
            constants_1.withDomainCertificateConfig(domains, (domainCertConfigPath) => {
                utils_1.openssl(['ca', '-config', domainCertConfigPath, '-in', csrFile, '-out', domainCertPath, '-keyfile', caKeyPath, '-cert', caCertPath, '-days', '825', '-batch']);
            });
        });
    });
}
function generateDomainCertificate ( domains ) { return tslib_1 . __awaiter ( this , void 0 , void 0 , function * ( ) { const domainPath = constants_1 . getStableDomainPath ( domains ) ; mkdirp_1 . sync ( constants_1 . pathForDomain ( domainPath ) ) ; debug ( ` ${ domains } ` ) ; let domainKeyPath = constants_1 . pathForDomain ( domainPath , 'private-key.key' ) ; generateKey ( domainKeyPath ) ; debug ( ` ${ domains } ` ) ; let csrFile = constants_1 . pathForDomain ( domainPath , ` ` ) ; constants_1 . withDomainSigningRequestConfig ( domains , ( configpath ) => { utils_1 . openssl ( [ 'req' , '-new' , '-config' , configpath , '-key' , domainKeyPath , '-out' , csrFile ] ) ; } ) ; debug ( ` ${ domains } ` ) ; let domainCertPath = constants_1 . pathForDomain ( domainPath , ` ` ) ; yield certificate_authority_1 . withCertificateAuthorityCredentials ( ( { caKeyPath , caCertPath } ) => { constants_1 . withDomainCertificateConfig ( domains , ( domainCertConfigPath ) => { utils_1 . openssl ( [ 'ca' , '-config' , domainCertConfigPath , '-in' , csrFile , '-out' , domainCertPath , '-keyfile' , caKeyPath , '-cert' , caCertPath , '-days' , '825' , '-batch' ] ) ; } ) ; } ) ; } ) ; }
Generate a domain certificate signed by the devcert root CA.
Generate a domain certificate signed by the devcert root CA .