How to use devcert - 6 common examples

To help you get started, we’ve selected a few devcert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Enalmada / next-reason-boilerplate / server.js View on Github external
.then(() => {
            if (dev || process.env.LOCAL_ENV) {
                // Always support localhost as it is what people expect
                server.listen(port, (err) => {
                    if (err) throw err;
                    // eslint-disable-next-line
                    console.log(`> Ready on http://localhost:${port}`);
                });

                // This will do a one time certificate password request the first time you start.
                // It will also attempt to add your certificateFor domain to hosts.  If you
                // get access errors, add "www.myweb.com 127.0.0.1" to hosts file manually.
                // devcert.certificateFor("www.myweb.com", {installCertutil: true}).then((ssl) => {
                devcert.certificateFor("www.myweb.com", {installCertutil: true}).then((ssl) => {
                    https.createServer(ssl, server).listen(devSslPort, (err) => {
                        if (err) throw err;
                        // eslint-disable-next-line
                        console.log(`> Ready on https://www.myweb.com:${devSslPort}`);
                    });
                });
            } else {
                server.listen(port, (err) => {
                    if (err) throw err;
                    // eslint-disable-next-line
                    console.log(`> Ready on http://localhost:${port}`);
                });
            }
        });
}
github wessberg / Polyfiller / src / util / cert / cert-util.ts View on Github external
export async function getCertificates({key, cert, production, host, https}: IGetCertificateOptions): Promise<{key: Buffer | undefined; cert: Buffer | undefined}> {
	// If a key and certificate was already given, use those two
	if (key != null && cert != null) return {key, cert};

	// Otherwise, if not in production, use devcert to generate a new certificate
	if (!production && https) {
		return await certificateFor(host);
	}

	// Return nothing
	return {key: undefined, cert: undefined};
}
github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / pwa-buildpack / lib / Utilities / configureHost.js View on Github external
const os = require('os');
const chalk = require('chalk');
const execa = require('execa');
const pkgDir = require('pkg-dir');
const { username } = os.userInfo();

/**
 * Monkeypatch devcert to fix
 * https://github.com/magento/pwa-studio/issues/679 which is blocked by
 * https://github.com/davewasmer/devcert/pull/30.
 * TODO: Remove this when a release of devcert without this bug is available
 */
const devCertUtils = require('devcert/dist/utils');
const MacOSPlatform = require('devcert/dist/platforms/darwin');
/* istanbul ignore next: temporary until we switch to devcert fork */
const proto = (MacOSPlatform.default || MacOSPlatform).prototype;
/* istanbul ignore next: temporary until we switch to devcert fork */
proto.isNSSInstalled = function() {
    try {
        return devCertUtils
            .run('brew list -1')
            .toString()
            .includes('\nnss\n');
    } catch (e) {
        return false;
    }
};

const DEFAULT_NAME = 'my-pwa';
const DEV_DOMAIN = 'local.pwadev';

const isSudoSession = () =>
github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / pwa-buildpack / lib / Utilities / configureHost.js View on Github external
debug('appears to be a sudo session already');
                    }
                } else {
                    debug(
                        'non-interactive! cleared UI timeout for getCert("%s")',
                        hostname
                    );
                    clearTimeout(timeout);
                    return reject(
                        new Error(
                            'Creating a local development domain requires an interactive terminal for the user to answer prompts. Run the development server (e.g. `yarn run watch:venia`) by itself in the terminal to continue.'
                        )
                    );
                }
            }
            const certBuffers = await devcert.certificateFor(hostname);
            debug('certBuffers arrived with %s', Object.keys(certBuffers));
            debug('success! cleared UI timeout for getCert("%s")', hostname);
            clearTimeout(timeout);
            resolve({
                key: certBuffers.key.toString('utf8'),
                cert: certBuffers.cert.toString('utf8')
            });
        } catch (e) {
            clearTimeout(timeout);
            debug(
                'failure! cleared UI timeout for getCert("%s"): %o',
                hostname,
                e
            );
            reject(e);
        }
github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / pwa-buildpack / lib / Utilities / configureHost.js View on Github external
const alreadyProvisioned = hostname => {
    const configuredDomains = devcert.configuredDomains();
    debug(
        'checking for %s in devcert.configuredDomains() === %o',
        hostname,
        configuredDomains
    );
    const isProvisioned = configuredDomains.includes(hostname);
    debug('isProvisioned? %s', isProvisioned);
    return isProvisioned;
};
github Jordaneisenburger / fallback-studio / src / pwa-studio / packages / pwa-buildpack / lib / Utilities / configureHost.js View on Github external
proto.isNSSInstalled = function() {
    try {
        return devCertUtils
            .run('brew list -1')
            .toString()
            .includes('\nnss\n');
    } catch (e) {
        return false;
    }
};

devcert

Generate trusted local SSL/TLS certificates for local SSL development

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis