How to use the devcert.certificateFor function in devcert

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
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);
        }

devcert

Generate trusted local SSL/TLS certificates for local SSL development

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis