devcert
Version:
Generate trusted local SSL/TLS certificates for local SSL development
111 lines • 14.1 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const debug_1 = tslib_1.__importDefault(require("debug"));
const crypto_1 = tslib_1.__importDefault(require("crypto"));
const fs_1 = require("fs");
const rimraf_1 = require("rimraf");
const shared_1 = require("./shared");
const utils_1 = require("../utils");
const user_interface_1 = tslib_1.__importDefault(require("../user-interface"));
const debug = debug_1.default('devcert:platforms:windows');
let encryptionKey;
class WindowsPlatform {
constructor() {
this.HOST_FILE_PATH = 'C:\\Windows\\System32\\Drivers\\etc\\hosts';
}
/**
* Windows is at least simple. Like macOS, most applications will delegate to
* the system trust store, which is updated with the confusingly named
* `certutil` exe (not the same as the NSS/Mozilla certutil). Firefox does it's
* own thing as usual, and getting a copy of NSS certutil onto the Windows
* machine to try updating the Firefox store is basically a nightmare, so we
* don't even try it - we just bail out to the GUI.
*/
addToTrustStores(certificatePath, options = {}) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
// IE, Chrome, system utils
debug('adding devcert root to Windows OS trust store');
try {
utils_1.run('certutil', ['-addstore', '-user', 'root', certificatePath]);
}
catch (e) {
e.output.map((buffer) => {
if (buffer) {
console.log(buffer.toString());
}
});
}
debug('adding devcert root to Firefox trust store');
// Firefox (don't even try NSS certutil, no easy install for Windows)
try {
yield shared_1.openCertificateInFirefox('start firefox', certificatePath);
}
catch (_a) {
debug('Error opening Firefox, most likely Firefox is not installed');
}
});
}
removeFromTrustStores(certificatePath) {
debug('removing devcert root from Windows OS trust store');
try {
console.warn('Removing old certificates from trust stores. You may be prompted to grant permission for this. It\'s safe to delete old devcert certificates.');
utils_1.run('certutil', ['-delstore', '-user', 'root', 'devcert']);
}
catch (e) {
debug(`failed to remove ${certificatePath} from Windows OS trust store, continuing. ${e.toString()}`);
}
}
addDomainToHostFileIfMissing(domain) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let hostsFileContents = fs_1.readFileSync(this.HOST_FILE_PATH, 'utf8');
if (!hostsFileContents.includes(domain)) {
yield utils_1.sudo(`echo 127.0.0.1 ${domain} >> ${this.HOST_FILE_PATH}`);
}
});
}
deleteProtectedFiles(filepath) {
shared_1.assertNotTouchingFiles(filepath, 'delete');
rimraf_1.sync(filepath);
}
readProtectedFile(filepath) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
shared_1.assertNotTouchingFiles(filepath, 'read');
if (!encryptionKey) {
encryptionKey = yield user_interface_1.default.getWindowsEncryptionPassword();
}
// Try to decrypt the file
try {
return this.decrypt(fs_1.readFileSync(filepath, 'utf8'), encryptionKey);
}
catch (e) {
// If it's a bad password, clear the cached copy and retry
if (e.message.indexOf('bad decrypt') >= -1) {
encryptionKey = null;
return yield this.readProtectedFile(filepath);
}
throw e;
}
});
}
writeProtectedFile(filepath, contents) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
shared_1.assertNotTouchingFiles(filepath, 'write');
if (!encryptionKey) {
encryptionKey = yield user_interface_1.default.getWindowsEncryptionPassword();
}
let encryptedContents = this.encrypt(contents, encryptionKey);
fs_1.writeFileSync(filepath, encryptedContents);
});
}
encrypt(text, key) {
let cipher = crypto_1.default.createCipher('aes256', new Buffer(key));
return cipher.update(text, 'utf8', 'hex') + cipher.final('hex');
}
decrypt(encrypted, key) {
let decipher = crypto_1.default.createDecipher('aes256', new Buffer(key));
return decipher.update(encrypted, 'hex', 'utf8') + decipher.final('utf8');
}
}
exports.default = WindowsPlatform;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2luMzIuanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbInBsYXRmb3Jtcy93aW4zMi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwREFBZ0M7QUFDaEMsNERBQTRCO0FBQzVCLDJCQUFrRTtBQUNsRSxtQ0FBd0M7QUFFeEMscUNBQTRFO0FBRTVFLG9DQUFxQztBQ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