diff --git a/README.md b/README.md index 11fccbb..0c83e4b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![npm](https://img.shields.io/npm/v/signcode.svg)](https://www.npmjs.com/packages/signcode) [![downloads](https://img.shields.io/npm/dm/signcode.svg)](https://www.npmjs.com/packages/signcode) -Sign Windows executables and installers from a Mac. +Sign Windows executables and installers from a Mac or a machine with osslsigncode installed. Works with `.pem`, `.p12`, and `.pfx` code signing files. @@ -59,6 +59,7 @@ signcode.verify({ path: '/Users/kevin/apps/myapp.exe' }, function (error) { | `password` | `String` | No | Password to the certificate or key. | | `passwordPath` | `String` | No | Path to a file containing the password for the certificate or key. | | `site` | `String` | No | Website URL to include in the signature. | +| `useLocal` | `Boolean` | No | `true` to use a locally installed version of osslsigncode (Linux anyone?). | ### Verification Options diff --git a/index.js b/index.js index ba7a4c5..94295ff 100644 --- a/index.js +++ b/index.js @@ -98,7 +98,7 @@ function spawnSign (options, callback) { spawnOptions.stdio = ['ignore', 'ignore', 'pipe'] } - var signcode = ChildProcess.spawn(getSigncodePath(), args, spawnOptions) + var signcode = ChildProcess.spawn(getSigncodePath(options), args, spawnOptions) var stderr = '' signcode.stderr.on('data', function (data) { @@ -144,7 +144,7 @@ function spawnVerify (options, callback) { ) } - var signcode = ChildProcess.spawn(getSigncodePath(), args) + var signcode = ChildProcess.spawn(getSigncodePath(options), args) var stdout = '' signcode.stdout.on('data', function (data) { @@ -186,6 +186,16 @@ function getOutputPath (inputPath, hash) { return path.join(path.dirname(inputPath), outputName) } -function getSigncodePath () { - return path.join(__dirname, 'vendor', process.platform, 'osslsigncode') +function getSigncodePath (options) { + var signcodePath = path.join(__dirname, 'vendor', process.platform, 'osslsigncode') + + if (options.useLocal) { + try { + ChildProcess.execSync('which osslsigncode') + signcodePath = 'osslsigncode' + } catch (e) { + console.warn('Could not find a local version of osslsigncode. Attempting to use the version packaged with signcode.') + } + } + return signcodePath }