devcert icon indicating copy to clipboard operation
devcert copied to clipboard

devcert is using debian specific commands for linux

Open guy-kdm opened this issue 5 years ago • 1 comments

The package update-ca-certificates used here is specific to debian, while most linux distributions use the trust package, which is also included in debian. The relevant flag being trust --extract-compat. We should switch, but a simple replacement of the commands didn't work, so not sure when I'll have time to learn about what's going on, meantime posting here.

guy-kdm avatar Feb 04 '20 05:02 guy-kdm

This may be a helpful reference for arch and other distros using trust https://archlinux.org/news/ca-certificates-update/

Edit: Got it working on manjaro using patch-package. Here is the generated patch - this will very likely break it on other distros but is a starting point at least

diff --git a/node_modules/devcert/dist/platforms/linux.js b/node_modules/devcert/dist/platforms/linux.js
index f378686..c1ada00 100644
--- a/node_modules/devcert/dist/platforms/linux.js
+++ b/node_modules/devcert/dist/platforms/linux.js
@@ -14,7 +14,7 @@ class LinuxPlatform {
         this.FIREFOX_NSS_DIR = path_1.default.join(process.env.HOME, '.mozilla/firefox/*');
         this.CHROME_NSS_DIR = path_1.default.join(process.env.HOME, '.pki/nssdb');
         this.FIREFOX_BIN_PATH = '/usr/bin/firefox';
-        this.CHROME_BIN_PATH = '/usr/bin/google-chrome';
+        this.CHROME_BIN_PATH = '/usr/bin/google-chrome-stable';
         this.HOST_FILE_PATH = '/etc/hosts';
     }
     /**
@@ -30,9 +30,9 @@ class LinuxPlatform {
         return tslib_1.__awaiter(this, void 0, void 0, function* () {
             debug('Adding devcert root CA to Linux system-wide trust stores');
             // run(`sudo cp ${ certificatePath } /etc/ssl/certs/devcert.crt`);
-            utils_1.run('sudo', ['cp', certificatePath, '/usr/local/share/ca-certificates/devcert.crt']);
+            utils_1.run('sudo', ['cp', certificatePath, '/etc/ca-certificates/trust-source/anchors/devcert.crt']);
             // run(`sudo bash -c "cat ${ certificatePath } >> /etc/ssl/certs/ca-certificates.crt"`);
-            utils_1.run('sudo', ['update-ca-certificates']);
+            utils_1.run('sudo', ['trust', 'extract-compat']);
             if (this.isFirefoxInstalled()) {
                 // Firefox
                 debug('Firefox install detected: adding devcert root CA to Firefox-specific trust stores ...');
@@ -70,11 +70,11 @@ class LinuxPlatform {
     }
     removeFromTrustStores(certificatePath) {
         try {
-            utils_1.run('sudo', ['rm', '/usr/local/share/ca-certificates/devcert.crt']);
-            utils_1.run('sudo', ['update-ca-certificates']);
+            utils_1.run('sudo', ['rm', '/etc/ca-certificates/trust-source/anchors/devcert.crt']);
+            utils_1.run('sudo', ['trust', 'extract-compat']);
         }
         catch (e) {
-            debug(`failed to remove ${certificatePath} from /usr/local/share/ca-certificates, continuing. ${e.toString()}`);
+            debug(`failed to remove ${certificatePath} from /etc/ca-certificates/trust-source/anchors, continuing. ${e.toString()}`);
         }
         if (command_exists_1.sync('certutil')) {
             if (this.isFirefoxInstalled()) {

qw-in avatar Dec 28 '20 19:12 qw-in