Bläddra i källkod

Windows Signing

Andrew Chalkley 8 år sedan
förälder
incheckning
44ba6203f0
4 ändrade filer med 52 tillägg och 3 borttagningar
  1. 4 1
      .gitignore
  2. 4 2
      package.json
  3. 23 0
      scripts/sign-installer-windows.js
  4. 21 0
      scripts/sign-windows.js

+ 4 - 1
.gitignore

@@ -37,4 +37,7 @@ typings
 .node_repl_history
 
 # Webstorm/JetBrains
-.idea
+.idea
+
+windows.p12
+sign.bat

+ 4 - 2
package.json

@@ -14,12 +14,14 @@
     "pack-linux": "electron-packager . --asar --asar-unpack=protocol-link.html --overwrite --platform=linux --arch=x64 --icon=resources/png/icon64.png --prune=true --out=out",
   
     "sign-mac": "electron-osx-sign out/Flasher.js-darwin-x64/Flasher.js.app",
-   
+    "sign-windows": "node ./scripts/sign-windows.js",
+    "sign-installer-windows": "node ./scripts/sign-installer-windows.js",
+
     "installer-windows": "node ./scripts/windows-installer.js",
     "installer-mac": "electron-installer-dmg --overwrite --out=out/installers/ out/Flasher.js-darwin-x64/Flasher.js.app Flasher.js --icon=resources/icon.icns",
     "installer-linux": "electron-installer-debian --src out/flasher.js-linux-x64/ --arch amd64 --config linux-config.json",
   
-    "dist-windows": "npm run pre-rebuild && npm run rebuild && npm run pack-windows && npm run installer-windows",
+    "dist-windows": "npm run pre-rebuild && npm run rebuild && npm run pack-windows && npm run sign-windows && npm run installer-windows && npm run sign-installer-windows",
     "dist-linux": "npm run pre-rebuild && npm run rebuild && npm run pack-linux && npm run installer-linux",
     "dist-mac": "npm run pack-mac && npm run sign-mac && npm run installer-mac"
   },

+ 23 - 0
scripts/sign-installer-windows.js

@@ -0,0 +1,23 @@
+"use strict";
+
+const fs = require("fs");
+const path = require('path');
+
+const rootPath = path.join(__dirname, '..');
+const outPath = path.join(rootPath, 'out');
+const packedPath = path.join(outPath, 'installers');
+const exec = require('child_process').execSync;
+
+fs.readdir(packedPath, (err, files) => {
+    const dllsAndExes = files.filter(file => {
+        return file.endsWith(".dll") || file.endsWith(".exe");
+    });
+    
+    dllsAndExes.forEach(run);
+});
+
+
+function run(file) {
+    exec(`signtool.exe sign /a /d "Flasher.js" /du https://github.com/ThingsSDK/flasher.js /s MY /n "Andrew Chalkley" /fd sha1 /t http://timestamp.verisign.com/scripts/timstamp.dll /v "${path.join(packedPath, file)}"`);
+    exec(`signtool.exe sign /a /d "Flasher.js" /du https://github.com/ThingsSDK/flasher.js /s MY /n "Andrew Chalkley" /fd sha256 /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td sha256 /as /v "${path.join(packedPath, file)}"`);
+}

+ 21 - 0
scripts/sign-windows.js

@@ -0,0 +1,21 @@
+"use strict";
+const fs = require("fs");
+const path = require('path');
+
+const rootPath = path.join(__dirname, '..');
+const outPath = path.join(rootPath, 'out');
+const packedPath = path.join(outPath, 'flasher.js-win32-x64');
+const exec = require('child_process').execSync;
+
+fs.readdir(packedPath, (err, files) => {
+    const dllsAndExes = files.filter(file => {
+        return file.endsWith(".dll") || file.endsWith(".exe");
+    });
+    dllsAndExes.forEach(run);
+});
+
+
+function run(file) {
+    exec(`signtool.exe sign /a /d "Flasher.js" /du https://github.com/ThingsSDK/flasher.js /s MY /n "Andrew Chalkley" /fd sha1 /t http://timestamp.verisign.com/scripts/timstamp.dll /v "${path.join(packedPath, file)}"`);
+    exec(`signtool.exe sign /a /d "Flasher.js" /du https://github.com/ThingsSDK/flasher.js /s MY /n "Andrew Chalkley" /fd sha256 /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td sha256 /as /v "${path.join(packedPath, file)}"`);
+}