src/crypto/openssl.js
async function generateCsr(opts, csrConfig, key) {
    let tempConfigFilePath;

    /* Write key to disk */
    const tempKeyFilePath = tempfile();
    await fs.writeFileAsync(tempKeyFilePath, key);
    opts.key = tempKeyFilePath;

    /* Write config to disk */
    if (csrConfig) {
        tempConfigFilePath = tempfile();
        await fs.writeFileAsync(tempConfigFilePath, csrConfig);
        opts.config = tempConfigFilePath;
    }

    /* Create CSR */
    const result = await openssl('req', opts);

    /* Clean up */
    await fs.unlinkAsync(tempKeyFilePath);

    if (tempConfigFilePath) {
        await fs.unlinkAsync(tempConfigFilePath);
    }

    return result;
}
async function generateCsr(opts, csrConfig, key) {
    let tempConfigFilePath;

    /* Write key to disk */
    const tempKeyFilePath = tempfile();
    await fs.writeFileAsync(tempKeyFilePath, key);
    opts.key = tempKeyFilePath;

    /* Write config to disk */
    if (csrConfig) {
        tempConfigFilePath = tempfile();
        await fs.writeFileAsync(tempConfigFilePath, csrConfig);
        opts.config = tempConfigFilePath;
    }

    /* Create CSR */
    const result = await openssl('req', opts);

    /* Clean up */
    await fs.unlinkAsync(tempKeyFilePath);

    if (tempConfigFilePath) {
        await fs.unlinkAsync(tempConfigFilePath);
    }

    return result;
}
async function generateCsr ( opts , csrConfig , key ) { let tempConfigFilePath ; /* Write key to disk */ const tempKeyFilePath = tempfile ( ) ; await fs . writeFileAsync ( tempKeyFilePath , key ) ; opts . key = tempKeyFilePath ; /* Write config to disk */ if ( csrConfig ) { tempConfigFilePath = tempfile ( ) ; await fs . writeFileAsync ( tempConfigFilePath , csrConfig ) ; opts . config = tempConfigFilePath ; } /* Create CSR */ const result = await openssl ( 'req' , opts ) ; /* Clean up */ await fs . unlinkAsync ( tempKeyFilePath ) ; if ( tempConfigFilePath ) { await fs . unlinkAsync ( tempConfigFilePath ) ; } return result ; }
Execute Certificate Signing Request generation

@private
@param {object} opts CSR options
@param {string} csrConfig CSR configuration file
@param {buffer} key CSR private key
@returns {Promise<buffer>} CSR
Execute Certificate Signing Request generation