Comparing version 1.12.0 to 1.12.1
171
HISTORY.md
# Change Log | ||
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). | ||
## [Unreleased](https://github.com/papakai/pem/compare/v1.11.0...HEAD) | ||
Generated by [auto-changelog](https://github.com/CookPete/auto-changelog) | ||
## [Unreleased](https://github.com/Dexus/pem/compare/v1.12.0...HEAD) | ||
### Fixed | ||
* fix #159; renamed helper methods [`#159`](https://github.com/Dexus/pem/issues/159) | ||
## [v1.12.0](https://github.com/Dexus/pem/compare/v1.11.2...v1.12.0) - 2017-09-28 | ||
### Commits | ||
* fix(package): consistent usage of -password -passin and -passout [`a7c5654`](https://github.com/Dexus/pem/commit/a7c56541ede4a8979eb83d513c6521efcbb1dd96) | ||
## [v1.11.2](https://github.com/Dexus/pem/compare/v1.11.1...v1.11.2) - 2017-09-21 | ||
### Fixed | ||
* fix(package): max 20 octets for serial (#141) [`#84`](https://github.com/Dexus/pem/issues/84) | ||
## [v1.11.1](https://github.com/Dexus/pem/compare/v1.11.0...v1.11.1) - 2017-09-20 | ||
### Merged | ||
* Update semantic-release to the latest version 🚀 [`#134`](https://github.com/papakai/pem/pull/134) | ||
* Update semantic-release to the latest version 🚀 [`#134`](https://github.com/Dexus/pem/pull/134) | ||
## [v1.11.0](https://github.com/papakai/pem/compare/v1.9.8...v1.11.0) - 2017-09-13 | ||
## [v1.11.0](https://github.com/Dexus/pem/compare/v1.10.1...v1.11.0) - 2017-09-13 | ||
### Commits | ||
* feat: use standard (https://standardjs.com) for coding style guide [`c48736b`](https://github.com/Dexus/pem/commit/c48736bfe4eebbcbccd7d29fe6718fe242046d40) | ||
## [v1.10.1](https://github.com/Dexus/pem/compare/v1.10.0...v1.10.1) - 2017-09-12 | ||
### Fixed | ||
* Fix #132 new version 1.10.1 [`#132`](https://github.com/papakai/pem/issues/132) | ||
* Fix #132 new version 1.10.1 [`#132`](https://github.com/Dexus/pem/issues/132) | ||
## [v1.9.8](https://github.com/papakai/pem/compare/v1.9.6...v1.9.8) - 2017-09-03 | ||
## [v1.10.0](https://github.com/Dexus/pem/compare/v1.9.8...v1.10.0) - 2017-09-03 | ||
### Commits | ||
* Support reading array of organizations in a CSR (#125) [`061a695`](https://github.com/Dexus/pem/commit/061a695c8ae44421e02b0f9474b227039fd41625) | ||
## [v1.9.8](https://github.com/Dexus/pem/compare/v1.9.6...v1.9.8) - 2017-09-03 | ||
### Merged | ||
* Allow array values for CSRs [`#124`](https://github.com/papakai/pem/pull/124) | ||
* Allow array values for CSRs [`#124`](https://github.com/Dexus/pem/pull/124) | ||
### Fixed | ||
* chore(package): update semantic-release to version 7.0.2 [`#128`](https://github.com/papakai/pem/issues/128) | ||
* chore(package): update semantic-release to version 7.0.2 [`#128`](https://github.com/Dexus/pem/issues/128) | ||
## [v1.9.6](https://github.com/papakai/pem/compare/v1.9.4...v1.9.6) - 2017-04-27 | ||
## [v1.9.6](https://github.com/Dexus/pem/compare/v1.9.4...v1.9.6) - 2017-04-27 | ||
### Merged | ||
* Update README [`#119`](https://github.com/papakai/pem/pull/119) | ||
* Revert "Regex support for new format with spaces" [`#113`](https://github.com/papakai/pem/pull/113) | ||
* Regex support for new format with spaces [`#111`](https://github.com/papakai/pem/pull/111) | ||
* Greenkeeper/initial [`#110`](https://github.com/papakai/pem/pull/110) | ||
* Update README [`#119`](https://github.com/Dexus/pem/pull/119) | ||
* Revert "Regex support for new format with spaces" [`#113`](https://github.com/Dexus/pem/pull/113) | ||
* Regex support for new format with spaces [`#111`](https://github.com/Dexus/pem/pull/111) | ||
* Greenkeeper/initial [`#110`](https://github.com/Dexus/pem/pull/110) | ||
## [v1.9.4](https://github.com/papakai/pem/compare/v1.8.3...v1.9.4) - 2016-12-01 | ||
## [v1.9.4](https://github.com/Dexus/pem/compare/v1.8.3...v1.9.4) - 2016-12-01 | ||
### Merged | ||
* Added noop callback (Node 7.0 deprecation warning) [`#91`](https://github.com/papakai/pem/pull/91) | ||
* Added noop callback (Node 7.0 deprecation warning) [`#91`](https://github.com/Dexus/pem/pull/91) | ||
### Fixed | ||
* Add support for DC Certificates fix #83 [`#83`](https://github.com/papakai/pem/issues/83) | ||
* Add support for DC Certificates fix #83 [`#83`](https://github.com/Dexus/pem/issues/83) | ||
* Only generate altNames config if it is a non-empty array (#78) [`https://github.com/andris9/pem/issues/77`](https://github.com/andris9/pem/issues/77) | ||
## [v1.8.3](https://github.com/papakai/pem/compare/1.8.1...v1.8.3) - 2016-05-02 | ||
## [v1.8.3](https://github.com/Dexus/pem/compare/1.8.1...v1.8.3) - 2016-05-02 | ||
### Merged | ||
* Update package.json versions [`#70`](https://github.com/papakai/pem/pull/70) | ||
* Refactor temp dir logic [`#63`](https://github.com/papakai/pem/pull/63) | ||
* Add CA certs to pkcs12 file and read pkcs12 files [`#62`](https://github.com/papakai/pem/pull/62) | ||
* Update package.json versions [`#70`](https://github.com/Dexus/pem/pull/70) | ||
* Refactor temp dir logic [`#63`](https://github.com/Dexus/pem/pull/63) | ||
* Add CA certs to pkcs12 file and read pkcs12 files [`#62`](https://github.com/Dexus/pem/pull/62) | ||
### Fixed | ||
* Allow commas in CSR fields (#74) [`#73`](https://github.com/papakai/pem/issues/73) | ||
* Allow commas in CSR fields (#74) [`#73`](https://github.com/Dexus/pem/issues/73) | ||
## [1.8.1](https://github.com/papakai/pem/compare/1.8.0...1.8.1) - 2015-09-20 | ||
## [1.8.1](https://github.com/Dexus/pem/compare/1.8.0...1.8.1) - 2015-09-20 | ||
### Merged | ||
* No match fix at preg_match_all [`#61`](https://github.com/papakai/pem/pull/61) | ||
* No match fix at preg_match_all [`#61`](https://github.com/Dexus/pem/pull/61) | ||
## [1.8.0](https://github.com/papakai/pem/compare/v1.7.1...1.8.0) - 2015-08-26 | ||
## [1.8.0](https://github.com/Dexus/pem/compare/v1.7.1...1.8.0) - 2015-08-26 | ||
### Merged | ||
* Adds method to verify a certificate's signing chain [`#60`](https://github.com/papakai/pem/pull/60) | ||
* Added functionality to export key and certificate to PKCS12 keystore [`#59`](https://github.com/papakai/pem/pull/59) | ||
* Added functionality to get modulus from a password protected key [`#53`](https://github.com/papakai/pem/pull/53) | ||
* Include Issuer Data with Fetch Cert Data Function [`#50`](https://github.com/papakai/pem/pull/50) | ||
* Adds method to verify a certificate's signing chain [`#60`](https://github.com/Dexus/pem/pull/60) | ||
* Added functionality to export key and certificate to PKCS12 keystore [`#59`](https://github.com/Dexus/pem/pull/59) | ||
* Added functionality to get modulus from a password protected key [`#53`](https://github.com/Dexus/pem/pull/53) | ||
* Include Issuer Data with Fetch Cert Data Function [`#50`](https://github.com/Dexus/pem/pull/50) | ||
## [v1.7.1](https://github.com/papakai/pem/compare/v1.7.0...v1.7.1) - 2015-02-27 | ||
## [v1.7.1](https://github.com/Dexus/pem/compare/v1.7.0...v1.7.1) - 2015-02-27 | ||
### Merged | ||
* Creating a CSR for an encrypted key [`#49`](https://github.com/papakai/pem/pull/49) | ||
* bump to 1.7.0 [`#2`](https://github.com/papakai/pem/pull/2) | ||
* Creating a CSR for an encrypted key [`#49`](https://github.com/Dexus/pem/pull/49) | ||
* bump to 1.7.0 [`#2`](https://github.com/Dexus/pem/pull/2) | ||
## [v1.7.0](https://github.com/papakai/pem/compare/v1.6.0...v1.7.0) - 2015-02-25 | ||
## [v1.7.0](https://github.com/Dexus/pem/compare/v1.6.0...v1.7.0) - 2015-02-25 | ||
### Merged | ||
* Private key encryption [`#48`](https://github.com/papakai/pem/pull/48) | ||
* Merge latest PEM version [`#1`](https://github.com/papakai/pem/pull/1) | ||
* Private key encryption [`#48`](https://github.com/Dexus/pem/pull/48) | ||
* Merge latest PEM version [`#1`](https://github.com/Dexus/pem/pull/1) | ||
## [v1.6.0](https://github.com/papakai/pem/compare/v1.5.0...v1.6.0) - 2015-02-24 | ||
## [v1.6.0](https://github.com/Dexus/pem/compare/v1.5.0...v1.6.0) - 2015-02-24 | ||
### Merged | ||
* Add function to create dhparam keys [`#47`](https://github.com/papakai/pem/pull/47) | ||
* Add function to create dhparam keys [`#47`](https://github.com/Dexus/pem/pull/47) | ||
## [v1.5.0](https://github.com/papakai/pem/compare/v1.4.6...v1.5.0) - 2015-01-19 | ||
## [v1.5.0](https://github.com/Dexus/pem/compare/v1.4.6...v1.5.0) - 2015-01-19 | ||
### Commits | ||
* Merge branch 'noamokman-feature-add-node-which' [`3124430`](https://github.com/papakai/pem/commit/3124430e401151732aad5aa531be4146291d60dd) | ||
* Merge branch 'noamokman-feature-add-node-which' [`3124430`](https://github.com/Dexus/pem/commit/3124430e401151732aad5aa531be4146291d60dd) | ||
## [v1.4.6](https://github.com/papakai/pem/compare/v1.4.5...v1.4.6) - 2015-01-18 | ||
## [v1.4.6](https://github.com/Dexus/pem/compare/v1.4.5...v1.4.6) - 2015-01-18 | ||
### Merged | ||
* Just added indentations [`#39`](https://github.com/papakai/pem/pull/39) | ||
* Fix to catch errors on spawn [`#38`](https://github.com/papakai/pem/pull/38) | ||
* Update pem.js [`#36`](https://github.com/papakai/pem/pull/36) | ||
* Just added indentations [`#39`](https://github.com/Dexus/pem/pull/39) | ||
* Fix to catch errors on spawn [`#38`](https://github.com/Dexus/pem/pull/38) | ||
* Update pem.js [`#36`](https://github.com/Dexus/pem/pull/36) | ||
## [v1.4.5](https://github.com/papakai/pem/compare/v1.4.4...v1.4.5) - 2015-01-05 | ||
## [v1.4.5](https://github.com/Dexus/pem/compare/v1.4.4...v1.4.5) - 2015-01-05 | ||
### Merged | ||
* Bugfix pathOpenSSL typo; Add environmental option for openssl binary [`#33`](https://github.com/papakai/pem/pull/33) | ||
* Add missing serviceCertificate & serial option to the doc [`#32`](https://github.com/papakai/pem/pull/32) | ||
* Bugfix pathOpenSSL typo; Add environmental option for openssl binary [`#33`](https://github.com/Dexus/pem/pull/33) | ||
* Add missing serviceCertificate & serial option to the doc [`#32`](https://github.com/Dexus/pem/pull/32) | ||
## [v1.4.4](https://github.com/papakai/pem/compare/v1.4.3...v1.4.4) - 2014-12-13 | ||
## [v1.4.4](https://github.com/Dexus/pem/compare/v1.4.3...v1.4.4) - 2014-12-13 | ||
### Merged | ||
* Update README.md [`#28`](https://github.com/papakai/pem/pull/28) | ||
* Add hash option for createCertificate(), default to sha256 [`#29`](https://github.com/papakai/pem/pull/29) | ||
* Update README.md [`#28`](https://github.com/Dexus/pem/pull/28) | ||
* Add hash option for createCertificate(), default to sha256 [`#29`](https://github.com/Dexus/pem/pull/29) | ||
## [v1.4.3](https://github.com/papakai/pem/compare/v1.4.2...v1.4.3) - 2014-12-09 | ||
## [v1.4.3](https://github.com/Dexus/pem/compare/v1.4.2...v1.4.3) - 2014-12-09 | ||
### Merged | ||
* Update README.md to correct copy/paste error [`#26`](https://github.com/papakai/pem/pull/26) | ||
* Add OpenSSL path config() [`#25`](https://github.com/papakai/pem/pull/25) | ||
* Update README.md to correct copy/paste error [`#26`](https://github.com/Dexus/pem/pull/26) | ||
* Add OpenSSL path config() [`#25`](https://github.com/Dexus/pem/pull/25) | ||
## [v1.4.2](https://github.com/papakai/pem/compare/v1.4.1...v1.4.2) - 2014-11-28 | ||
## [v1.4.2](https://github.com/Dexus/pem/compare/v1.4.1...v1.4.2) - 2014-11-28 | ||
### Merged | ||
* getModulus() will now accept Buffers [`#24`](https://github.com/papakai/pem/pull/24) | ||
* getModulus() will now accept Buffers [`#24`](https://github.com/Dexus/pem/pull/24) | ||
## [v1.4.1](https://github.com/papakai/pem/compare/v1.4.0...v1.4.1) - 2014-05-10 | ||
## [v1.4.1](https://github.com/Dexus/pem/compare/v1.4.0...v1.4.1) - 2014-05-10 | ||
### Merged | ||
* fix wildcard certificate creation [`#19`](https://github.com/papakai/pem/pull/19) | ||
* fix wildcard certificate creation [`#19`](https://github.com/Dexus/pem/pull/19) | ||
## [v1.4.0](https://github.com/papakai/pem/compare/v1.3.0...v1.4.0) - 2014-03-27 | ||
## [v1.4.0](https://github.com/Dexus/pem/compare/v1.3.0...v1.4.0) - 2014-03-27 | ||
### Merged | ||
* Change to BEGIN(\sNEW)? CERTIFICATE REQUEST [`#15`](https://github.com/papakai/pem/pull/15) | ||
* Change to BEGIN(\sNEW)? CERTIFICATE REQUEST [`#15`](https://github.com/Dexus/pem/pull/15) | ||
## [v1.3.0](https://github.com/papakai/pem/compare/v0.2.2...v1.3.0) - 2014-03-18 | ||
## [v1.3.0](https://github.com/Dexus/pem/compare/v0.2.2...v1.3.0) - 2014-03-18 | ||
### Merged | ||
* Change SAN CSR process. [`#13`](https://github.com/papakai/pem/pull/13) | ||
* add SAN integration for readCertificateInfo [`#12`](https://github.com/papakai/pem/pull/12) | ||
* Easier to set temp dir, and all temp files are unlinked after use [`#11`](https://github.com/papakai/pem/pull/11) | ||
* altNames option to set subjectAltName [`#10`](https://github.com/papakai/pem/pull/10) | ||
* Change SAN CSR process. [`#13`](https://github.com/Dexus/pem/pull/13) | ||
* add SAN integration for readCertificateInfo [`#12`](https://github.com/Dexus/pem/pull/12) | ||
* Easier to set temp dir, and all temp files are unlinked after use [`#11`](https://github.com/Dexus/pem/pull/11) | ||
* altNames option to set subjectAltName [`#10`](https://github.com/Dexus/pem/pull/10) | ||
## [v0.2.2](https://github.com/papakai/pem/compare/v0.2.1...v0.2.2) - 2013-06-17 | ||
## [v0.2.2](https://github.com/Dexus/pem/compare/v0.2.1...v0.2.2) - 2013-06-17 | ||
### Merged | ||
* Add certificate validity information to readCertificateInfo callback [`#9`](https://github.com/papakai/pem/pull/9) | ||
* Add certificate validity information to readCertificateInfo callback [`#9`](https://github.com/Dexus/pem/pull/9) | ||
## [v0.2.1](https://github.com/papakai/pem/compare/v0.2.0...v0.2.1) - 2013-06-09 | ||
## [v0.2.1](https://github.com/Dexus/pem/compare/v0.2.0...v0.2.1) - 2013-06-09 | ||
### Merged | ||
* update README.md, and improve unit test for getModulus function [`#8`](https://github.com/papakai/pem/pull/8) | ||
* add getModulus function [`#7`](https://github.com/papakai/pem/pull/7) | ||
* update README.md, and improve unit test for getModulus function [`#8`](https://github.com/Dexus/pem/pull/8) | ||
* add getModulus function [`#7`](https://github.com/Dexus/pem/pull/7) | ||
## [v0.2.0](https://github.com/papakai/pem/compare/v0.1.0...v0.2.0) - 2013-04-17 | ||
## [v0.2.0](https://github.com/Dexus/pem/compare/v0.1.0...v0.2.0) - 2013-04-17 | ||
### Merged | ||
* Add getFingerprint, fix intermittent failure [`#1`](https://github.com/papakai/pem/pull/1) | ||
* Add getFingerprint, fix intermittent failure [`#1`](https://github.com/Dexus/pem/pull/1) | ||
@@ -174,2 +207,2 @@ | ||
### Commits | ||
* added tests [`85d2d09`](https://github.com/papakai/pem/commit/85d2d0992d9a2ea055f5cea9fa669f467f7f5f28) | ||
* added tests [`85d2d09`](https://github.com/Dexus/pem/commit/85d2d0992d9a2ea055f5cea9fa669f467f7f5f28) |
@@ -8,33 +8,40 @@ 'use strict' | ||
var tempDir = process.env.PEMJS_TMPDIR || osTmpdir() | ||
/** | ||
* pem helper module | ||
* | ||
* @module helper | ||
*/ | ||
var ciphers = ['aes128', 'aes192', 'aes256', 'camellia128', 'camellia192', 'camellia256', 'des', 'des3', 'idea'] | ||
// cipherPassword returns an array of supported ciphers. | ||
module.exports.ciphers = ciphers | ||
/** | ||
* list of supported ciphers | ||
* @type {Array} | ||
*/ | ||
module.exports.ciphers = ['aes128', 'aes192', 'aes256', 'camellia128', 'camellia192', 'camellia256', 'des', 'des3', 'idea'] | ||
var ciphers = module.exports.ciphers | ||
/** | ||
* Creates a PasswordFile to hide the password form process infos via `ps auxf` etc. | ||
* | ||
* @param {Object} [options] object of cipher, password and passType {cipher:'aes128', password:'xxxx', passType:"in/out/word"}, if the object empty we do nothing | ||
* @param {Object} options object of cipher, password and passType, mustPass, {cipher:'aes128', password:'xxxx', passType:"in/out/word"}, if the object empty we do nothing | ||
* @param {Object} params params will be extended with the data that need for the openssl command. IS USED AS POINTER! | ||
* @param {String} PasswordFile PasswordFile is the filePath that later need to deleted, after the openssl command. IS USED AS POINTER! | ||
* @return {Boolean} result | ||
*/ | ||
module.exports.helperCreatePasswordFile = function (options, params, PasswordFile) { | ||
if (Object.keys(options).length < 3) { | ||
module.exports.createPasswordFile = function (options, params, PasswordFile) { | ||
if (!options || !options.hasOwnProperty('password') || !options.hasOwnProperty('passType') || !/^(word|in|out)$/.test(options.passType)) { | ||
return false | ||
} | ||
if (!(options.password && options.passType)) { | ||
return false | ||
PasswordFile = pathlib.join(tempDir, crypto.randomBytes(20).toString('hex')) | ||
options.password = options.password.trim() | ||
if (options.password === '') { | ||
options.mustPass = true | ||
} | ||
if (options.passType && options.passType.trim().length === 0) { | ||
return false | ||
} | ||
PasswordFile = pathlib.join(tempDir, crypto.randomBytes(20).toString('hex')) | ||
fs.writeFileSync(PasswordFile, options.password) | ||
if (options.cipher && (Number(ciphers.indexOf(options.cipher)) !== -1)) { | ||
if (options.cipher && (ciphers.indexOf(options.cipher) !== -1)) { | ||
params.push('-' + options.cipher) | ||
} | ||
params.push('-pass' + (options.passType && options.passType.trim() === 'word' ? 'word' : (options.passType && options.passType.trim() === 'out' ? 'out' : 'in'))) | ||
if (options && options.mustPass === 'password') { | ||
params.push('-pass' + options.passType) | ||
if (options.mustPass) { | ||
params.push('pass:' + options.password) | ||
} else { | ||
fs.writeFileSync(PasswordFile, options.password) | ||
params.push('file:' + PasswordFile) | ||
@@ -47,14 +54,13 @@ } | ||
* Deletes a file or an array of files | ||
* | ||
* @param {Array} files array of files that shoudld be deleted | ||
* @param {Function} callback Callback function with an error object | ||
*/ | ||
module.exports.helperDeleteTempFiles = function (files, callback) { | ||
module.exports.deleteTempFiles = function (files, callback) { | ||
var rmFiles = [] | ||
if (typeof files === 'string') { | ||
rmFiles.push(files) | ||
} else if (typeof files === 'object') { | ||
} else if (Array.isArray(files)) { | ||
rmFiles = files | ||
} else { | ||
return callback(new Error('Unexcepted fiels param only string or array supported')) | ||
return callback(new Error('Unexcepted files parameter type; only string or array supported')) | ||
} | ||
@@ -61,0 +67,0 @@ var deleteSeries = function (list, finalCallback) { |
var Buffer = require('safe-buffer').Buffer | ||
var helper = require('./helper.js') | ||
var spawn = require('child_process').spawn | ||
var cpspawn = require('child_process').spawn | ||
var pathlib = require('path') | ||
@@ -13,3 +13,11 @@ var fs = require('fs') | ||
/** | ||
* pem openssl module | ||
* | ||
* @module openssl | ||
*/ | ||
/** | ||
* configue this openssl module | ||
* | ||
* @static | ||
* @param {String} option name e.g. pathOpenSSL, openSslVersion; TODO rethink nomenclature | ||
@@ -24,2 +32,4 @@ * @param {*} value value | ||
* get configuration setting value | ||
* | ||
* @static | ||
* @param {String} option name | ||
@@ -33,2 +43,4 @@ */ | ||
* Spawn an openssl command | ||
* | ||
* @static | ||
* @param {Array} params Array of openssl command line parameters | ||
@@ -39,3 +51,3 @@ * @param {String} searchStr String to use to find data | ||
*/ | ||
function execOpenSSL (params, searchStr, tmpfiles, callback) { | ||
function exec (params, searchStr, tmpfiles, callback) { | ||
if (!callback && typeof tmpfiles === 'function') { | ||
@@ -65,3 +77,3 @@ callback = tmpfiles | ||
if ((end = stdout.match(new RegExp('^\\-+END ' + searchStr + '\\-+', 'm')))) { | ||
end = end.index + (end[0] || '').length | ||
end = end.index + end[0].length | ||
} else { | ||
@@ -81,2 +93,4 @@ end = -1 | ||
* Spawn an openssl command and get binary output | ||
* | ||
* @static | ||
* @param {Array} params Array of openssl command line parameters | ||
@@ -86,3 +100,3 @@ * @param {Array} [tmpfiles] list of temporary files | ||
*/ | ||
function execBinaryOpenSSL (params, tmpfiles, callback) { | ||
function execBinary (params, tmpfiles, callback) { | ||
if (!callback && typeof tmpfiles === 'function') { | ||
@@ -102,2 +116,4 @@ callback = tmpfiles | ||
* Generically spawn openSSL, without processing the result | ||
* | ||
* @static | ||
* @param {Array} params The parameters to pass to openssl | ||
@@ -107,3 +123,3 @@ * @param {Boolean} binary Output of openssl is binary or text | ||
*/ | ||
function spawnOpenSSL (params, binary, callback) { | ||
function spawn (params, binary, callback) { | ||
var pathBin = get('pathOpenSSL') || process.env.OPENSSL_BIN || 'openssl' | ||
@@ -115,3 +131,3 @@ | ||
} | ||
var openssl = spawn(pathBin, params) | ||
var openssl = cpspawn(pathBin, params) | ||
var stderr = '' | ||
@@ -122,3 +138,3 @@ | ||
if (!binary) { | ||
stdout += (data || '').toString('binary') | ||
stdout += data.toString('binary') | ||
} else { | ||
@@ -130,3 +146,3 @@ stdout = Buffer.concat([stdout, data]) | ||
openssl.stderr.on('data', function (data) { | ||
stderr += (data || '').toString('binary') | ||
stderr += data.toString('binary') | ||
}) | ||
@@ -179,5 +195,7 @@ // We need both the return code and access to all of stdout. Stdout isn't | ||
* Wrapper for spawn method | ||
* | ||
* @static | ||
* @param {Array} params The parameters to pass to openssl | ||
* @param {Array} [tmpfiles] list of temporary files | ||
* @param {Boolean} binary Output of openssl is binary or text | ||
* @param {Boolean} [binary] Output of openssl is binary or text | ||
* @param {Function} callback Called with (error, exitCode, stdout, stderr) | ||
@@ -195,3 +213,3 @@ */ | ||
if (tmpfiles) { | ||
tmpfiles = [].concat(tmpfiles || []) | ||
tmpfiles = [].concat(tmpfiles) | ||
params.forEach(function (value, i) { | ||
@@ -216,4 +234,4 @@ var fpath | ||
spawnOpenSSL(params, binary, function (err, code, stdout, stderr) { | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
spawn(params, binary, function (err, code, stdout, stderr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
callback(err || fsErr, code, stdout, stderr) | ||
@@ -226,2 +244,4 @@ }) | ||
* Validates the pathBin for the openssl command | ||
* | ||
* @private | ||
* @param {String} pathBin The path to OpenSSL Bin | ||
@@ -235,3 +255,2 @@ * @param {Function} callback Callback function with an error object | ||
} | ||
callback() | ||
@@ -242,3 +261,3 @@ }) | ||
/* Once PEM is imported, the openSslVersion is set with this function. */ | ||
spawnOpenSSL(['version'], false, function (err, code, stdout, stderr) { | ||
spawn(['version'], false, function (err, code, stdout, stderr) { | ||
var text = String(stdout) + '\n' + String(stderr) + '\n' + String(err) | ||
@@ -250,5 +269,5 @@ var tmp = text.match(/^LibreSSL/i) | ||
module.exports = { | ||
exec: execOpenSSL, | ||
execBinary: execBinaryOpenSSL, | ||
spawn: spawnOpenSSL, | ||
exec: exec, | ||
execBinary: execBinary, | ||
spawn: spawn, | ||
spawnWrapper: spawnWrapper, | ||
@@ -255,0 +274,0 @@ set: set, |
'use strict' | ||
/** | ||
* pem module | ||
* | ||
* @module pem | ||
*/ | ||
var Buffer = require('safe-buffer').Buffer | ||
@@ -24,2 +30,7 @@ var net = require('net') | ||
module.exports.config = config | ||
/** | ||
* quick access the convert module | ||
* @type {module:convert} | ||
*/ | ||
module.exports.convert = require('./convert.js') | ||
@@ -35,7 +46,6 @@ var KEY_START = '-----BEGIN PRIVATE KEY-----' | ||
// PUBLIC API | ||
/** | ||
* Creates a private key | ||
* | ||
* @static | ||
* @param {Number} [keyBitsize=2048] Size of the key, defaults to 2048bit | ||
@@ -61,3 +71,3 @@ * @param {Object} [options] object of cipher and password {cipher:'aes128',password:'xxx'}, defaults empty object | ||
if (options && options.cipher && (Number(helper.ciphers.indexOf(options.cipher)) !== -1) && options.password) { | ||
helper.helperCreatePasswordFile({'cipher': options.cipher, 'password': options.password, 'passType': 'out'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': options.cipher, 'password': options.password, 'passType': 'out'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
@@ -76,3 +86,3 @@ | ||
} | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
done(sslErr || fsErr) | ||
@@ -86,2 +96,3 @@ }) | ||
* | ||
* @static | ||
* @param {Number} [keyBitsize=512] Size of the key, defaults to 512bit | ||
@@ -116,3 +127,3 @@ * @param {Function} callback Callback function with an error object and {dhparam} | ||
* Creates a ecparam key | ||
* | ||
* @static | ||
* @param {String} [keyName=secp256k1] Name of the key, defaults to secp256k1 | ||
@@ -149,6 +160,5 @@ * @param {Function} callback Callback function with an error object and {ecparam} | ||
* Creates a Certificate Signing Request | ||
* | ||
* If client key is undefined, a new key is created automatically. The used key is included | ||
* in the callback return as clientKey | ||
* | ||
* @static | ||
* @param {Object} [options] Optional options object | ||
@@ -244,3 +254,3 @@ * @param {String} [options.clientKey] Optional client key to use | ||
if (options.clientKeyPassword) { | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': options.clientKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': options.clientKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
@@ -259,3 +269,3 @@ | ||
} | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
done(sslErr || fsErr) | ||
@@ -270,3 +280,3 @@ }) | ||
* can be used as with createCSR. | ||
* | ||
* @static | ||
* @param {Object} [options] Optional options object | ||
@@ -350,3 +360,3 @@ * @param {String} [options.serviceKey] Private key for signing the certificate, if not defined a new one is generated | ||
if (options.serviceKeyPassword) { | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': options.serviceKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': options.serviceKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
@@ -359,3 +369,3 @@ tmpfiles.push(options.serviceCertificate) | ||
if (options.serviceKeyPassword) { | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': options.serviceKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': options.serviceKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
@@ -377,3 +387,3 @@ tmpfiles.push(options.serviceKey) | ||
if (options.clientKeyPassword) { | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': options.clientKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': options.clientKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
@@ -395,3 +405,3 @@ | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
done(sslErr || fsErr) | ||
@@ -404,3 +414,3 @@ }) | ||
* Exports a public key from a private key, CSR or certificate | ||
* | ||
* @static | ||
* @param {String} certificate PEM encoded private key, CSR or certificate | ||
@@ -453,3 +463,3 @@ * @param {Function} callback Callback function with an error object and {publicKey} | ||
* Reads subject data from a certificate or a CSR | ||
* | ||
* @static | ||
* @param {String} certificate PEM encoded CSR or certificate | ||
@@ -485,3 +495,3 @@ * @param {Function} callback Callback function with an error object and {country, state, locality, organization, organizationUnit, commonName, emailAddress} | ||
* get the modulus from a certificate, a CSR or a private key | ||
* | ||
* @static | ||
* @param {String} certificate PEM encoded, CSR PEM encoded, or private key | ||
@@ -529,3 +539,3 @@ * @param {String} [password] password for the certificate | ||
if (password) { | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': password, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': password, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
@@ -547,3 +557,3 @@ | ||
} | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
done(sslErr || fsErr) | ||
@@ -556,3 +566,3 @@ }) | ||
* get the size and prime of DH parameters | ||
* | ||
* @static | ||
* @param {String} DH parameters PEM encoded | ||
@@ -604,2 +614,3 @@ * @param {Function} callback Callback function with an error object and {size, prime} | ||
* config the pem module | ||
* @static | ||
* @param {Object} options | ||
@@ -615,3 +626,3 @@ */ | ||
* Gets the fingerprint for a certificate | ||
* | ||
* @static | ||
* @param {String} PEM encoded certificate | ||
@@ -654,3 +665,3 @@ * @param {String} [hash] hash function to use (either `md5`, `sha1` or `sha256`, defaults to `sha1`) | ||
* Export private key and certificate to a PKCS12 keystore | ||
* | ||
* @static | ||
* @param {String} PEM encoded private key | ||
@@ -674,7 +685,7 @@ * @param {String} PEM encoded certificate | ||
// create password file for the import "-passin" | ||
helper.helperCreatePasswordFile({'cipher': options.cipher, 'password': options.clientKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': options.cipher, 'password': options.clientKeyPassword, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
// NOTICE: The password field is needed! self if it is empty. | ||
// create password file for the password "-password" | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': password, 'passType': 'word'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': password, 'passType': 'word'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
@@ -704,3 +715,3 @@ params.push('-in') | ||
} | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
done(sslErr || fsErr) | ||
@@ -711,2 +722,9 @@ }) | ||
/** | ||
* read sslcert data from Pkcs12 file. Results are provided in callback response in object notation ({cert: .., ca:..., key:...}) | ||
* @static | ||
* @param {Buffer|String} bufferOrPath Buffer or path to file | ||
* @param {Object} [options] openssl options | ||
* @param {Function} callback Called with error object and sslcert bundle object | ||
*/ | ||
function readPkcs12 (bufferOrPath, options, callback) { | ||
@@ -724,5 +742,3 @@ if (!callback && typeof options === 'function') { | ||
if (options.p12Password) { | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': options.p12Password, 'passType': 'in'}, args, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
helper.createPasswordFile({'cipher': '', 'password': options.p12Password, 'passType': 'in'}, args, delTempPWFiles[delTempPWFiles.length]) | ||
@@ -735,3 +751,3 @@ if (Buffer.isBuffer(bufferOrPath)) { | ||
if (options.clientKeyPassword) { | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': options.clientKeyPassword, 'passType': 'out'}, args, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': options.clientKeyPassword, 'passType': 'out'}, args, delTempPWFiles[delTempPWFiles.length]) | ||
} else { | ||
@@ -773,3 +789,3 @@ args.push('-nodes') | ||
} | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
done(sslErr || fsErr) | ||
@@ -782,2 +798,3 @@ }) | ||
* Check a certificate | ||
* @static | ||
* @param {String} PEM encoded certificate | ||
@@ -805,3 +822,3 @@ * @param {String} [passphrase] password for the certificate | ||
if (passphrase) { | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': passphrase, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': passphrase, 'passType': 'in'}, params, delTempPWFiles[delTempPWFiles.length]) | ||
} | ||
@@ -826,3 +843,3 @@ | ||
} | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
done(sslErr || fsErr) | ||
@@ -835,2 +852,3 @@ }) | ||
* check a PKCS#12 file (.pfx or.p12) | ||
* @static | ||
* @param {Buffer|String} bufferOrPath PKCS#12 certificate | ||
@@ -850,3 +868,3 @@ * @param {String} [passphrase] optional passphrase which will be used to open the keystore | ||
helper.helperCreatePasswordFile({'cipher': '', 'password': passphrase, 'passType': 'in'}, args, delTempPWFiles[delTempPWFiles.length]) | ||
helper.createPasswordFile({'cipher': '', 'password': passphrase, 'passType': 'in'}, args, delTempPWFiles[delTempPWFiles.length]) | ||
@@ -865,3 +883,3 @@ if (Buffer.isBuffer(bufferOrPath)) { | ||
} | ||
helper.helperDeleteTempFiles(delTempPWFiles, function (fsErr) { | ||
helper.deleteTempFiles(delTempPWFiles, function (fsErr) { | ||
done(sslErr || fsErr) | ||
@@ -874,3 +892,3 @@ }) | ||
* Verifies the signing chain of the passed certificate | ||
* | ||
* @static | ||
* @param {String} PEM encoded certificate | ||
@@ -906,3 +924,2 @@ * @param {Array} List of CA certificates | ||
// HELPER FUNCTIONS | ||
function fetchCertificateData (certData, callback) { | ||
@@ -909,0 +926,0 @@ certData = (certData || '').toString() |
@@ -1,65 +0,1 @@ | ||
{ | ||
"author": "Andris Reinman <andris@kreata.ee>", | ||
"contributors": [ | ||
{ | ||
"name": "Josef Fröhle", | ||
"email": "github@josef-froehle.de", | ||
"url": "https://www.josef-froehle.de/" | ||
} | ||
], | ||
"license": "MIT", | ||
"name": "pem", | ||
"description": "Create private keys and certificates with node.js and io.js", | ||
"version": "1.12.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Dexus/pem.git" | ||
}, | ||
"main": "lib/pem", | ||
"scripts": { | ||
"changelog": "auto-changelog --output HISTORY.md", | ||
"coverage": "cross-env NODE_ENV=development nyc ./node_modules/.bin/_mocha --opts mocha.opts $(find . -type f -name '*.spec.js' ! -path './nyc_output/*' ! -path './coverage/*' ! -path './node_modules/*')", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post", | ||
"lint": "eslint --fix --config=./.eslintrc.js *.js *.md *.json lib/*.js test/*.js", | ||
"test": "npm run lint --silent && npm run coverage --silent" | ||
}, | ||
"nyc": { | ||
"reporter": [ | ||
"html", | ||
"text" | ||
], | ||
"exclude": [ | ||
"**/*.spec.js", | ||
"test/pem.helper.js" | ||
] | ||
}, | ||
"dependencies": { | ||
"safe-buffer": "^5.1.1", | ||
"md5": "^2.2.1", | ||
"os-tmpdir": "^1.0.1", | ||
"which": "^1.2.4" | ||
}, | ||
"devDependencies": { | ||
"auto-changelog": "^0.3.2", | ||
"chai": "^4.1.2", | ||
"cross-env": "^5.0.5", | ||
"dirty-chai": "^2.0.1", | ||
"eslint": "^4.7.1", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-json": "^1.2.0", | ||
"eslint-plugin-markdown": "^1.0.0-beta.6", | ||
"eslint-plugin-node": "^5.1.1", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^3.0.1", | ||
"mocha": "^3.5.3", | ||
"nyc": "^11.2.1", | ||
"semantic-release": "^8.0.3" | ||
}, | ||
"engines": { | ||
"node": ">=4.0.0" | ||
}, | ||
"release": { | ||
"debug": false | ||
} | ||
} | ||
{"author":"Andris Reinman <andris@kreata.ee>","contributors":[{"name":"Josef Fröhle","email":"github@josef-froehle.de","url":"https://www.josef-froehle.de/"}],"license":"MIT","name":"pem","description":"Create private keys and certificates with node.js and io.js","version":"1.12.1","repository":{"type":"git","url":"https://github.com/Dexus/pem.git"},"main":"lib/pem","scripts":{"documentation":"npm run docco --silent && npm run jsdoc --silent","docco":"docco -l parallel -o docs/docco lib/helper.js lib/openssl.js lib/pem.js","jsdoc":"jsdoc -c jsdoc.json","changelog":"auto-changelog --output HISTORY.md","coverage":"cross-env NODE_ENV=development nyc ./node_modules/.bin/_mocha --opts mocha.opts $(find . -type f -name '*.spec.js' ! -path './nyc_output/*' ! -path './coverage/*' ! -path './node_modules/*')","semantic-release":"semantic-release pre && npm publish && semantic-release post","lint":"eslint --fix --config=./.eslintrc.js *.js *.md *.json lib/*.js test/*.js test/*.spec.js","test":"npm run lint --silent && npm run coverage --silent"},"nyc":{"reporter":["html","text"],"exclude":["**/*.spec.js","test/pem.helper.js"]},"dependencies":{"safe-buffer":"^5.1.1","md5":"^2.2.1","os-tmpdir":"^1.0.1","which":"^1.2.4"},"devDependencies":{"auto-changelog":"^0.3.5","chai":"^4.1.2","cross-env":"^5.0.5","dirty-chai":"^2.0.1","docco":"^0.7.0","@deineagenturug/docdash":"^0.4.1","eslint":"^4.8.0","eslint-config-standard":"^10.2.1","eslint-plugin-import":"^2.7.0","eslint-plugin-json":"^1.2.0","eslint-plugin-markdown":"^1.0.0-beta.7","eslint-plugin-node":"^5.2.0","eslint-plugin-promise":"^3.5.0","eslint-plugin-standard":"^3.0.1","jsdoc":"^3.5.5","mocha":"^4.0.1","nyc":"^11.2.1","semantic-release":"^8.1.1"},"engines":{"node":">=4.0.0"},"release":{"debug":false}} |
@@ -10,2 +10,6 @@ pem | ||
[![npm version](https://badge.fury.io/js/pem.svg)](http://badge.fury.io/js/pem) | ||
[![npm downloads](https://img.shields.io/npm/dt/pem.svg)](https://www.npmjs.com/package/pem) | ||
[![pem documentation](https://img.shields.io/badge/pem-documentation-0099ff.svg?style=flat)](https://www.deineagentur.com/projects/pem) | ||
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard) | ||
@@ -12,0 +16,0 @@ |
@@ -9,2 +9,8 @@ 'use strict' | ||
process.env.PEMJS_TMPDIR = './tmp' | ||
if (process.env.TRAVIS === 'true' && process.env.OPENSSL_DIR !== '') { | ||
process.env.OPENSSL_BIN = '/openssl/bin/openssl' | ||
} | ||
function checkTmpEmpty () { | ||
@@ -11,0 +17,0 @@ expect(fs.readdirSync(process.env.PEMJS_TMPDIR)).to.be.empty() |
@@ -11,8 +11,2 @@ 'use strict' | ||
process.env.PEMJS_TMPDIR = './tmp' | ||
if (process.env.TRAVIS === 'true' && process.env.OPENSSL_DIR !== '') { | ||
process.env.OPENSSL_BIN = '/openssl/bin/openssl' | ||
} | ||
describe('General Tests', function () { | ||
@@ -19,0 +13,0 @@ this.timeout(300000)// 5 minutes |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137729
32
2783
334
18
19