{"name":"node-easy-cert","version":"1.3.2","description":"A tool for managing self-signed certifications","main":"dist/index.js","scripts":{"test":"sh test/test.sh","lint":"eslint ./src","build":"npm run lint && node gulpfile.js","prepublish":"npm run build && npm run test"},"repository":{"type":"git","url":"git+https://github.com/ottomao/node-easy-cert.git"},"keywords":["certification","https"],"author":"","license":"MIT","dependencies":{"async-task-mgr":"^1.1.0","colorful":"^2.1.0","commander":"^2.9.0","node-forge":"^0.6.42","node-powershell":"^3.3.1"},"devDependencies":{"babel-core":"^6.26.0","babel-eslint":"^7.1.1","babel-polyfill":"^6.13.0","babel-preset-es2015":"^6.13.2","babel-preset-stage-0":"^6.5.0","babel-register":"^6.11.6","eslint":"^4.15.0","eslint-config-standard":"^11.0.0","eslint-plugin-import":"^2.2.0","eslint-plugin-node":"^6.0.1","eslint-plugin-promise":"^3.8.0","eslint-plugin-standard":"^3.1.0","gulp":"^3.9.1","gulp-babel":"^7.0.0"},"gitHead":"8e0022751a3d10d333619badcb8fc5e5e43ef10d","bugs":{"url":"https://github.com/ottomao/node-easy-cert/issues"},"homepage":"https://github.com/ottomao/node-easy-cert#readme","_id":"node-easy-cert@1.3.2","_npmVersion":"6.4.1","_nodeVersion":"10.15.3","_npmUser":{"name":"ottomao","email":"ottomao@gmail.com"},"dist":{"integrity":"sha512-xS9qs8Lj/kxv14Z/jDpj7e4BXeLPgHhObZmsPQiR3QIGOq1gfJYXUUB6Ck9K/6ZuOin+O5TK6Mcue+afEi0LyQ==","shasum":"10929040cbd5ce21012f3d9acae7e44a7b625214","tarball":"http://registry-npm.ywwl.com/node-easy-cert/download/node-easy-cert-1.3.2.tgz","fileCount":18,"unpackedSize":36864,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd/ENXCRA9TVsSAnZWagAAbFkQAIJbsPSh2AeBNFJJed3q\nhHE+/MhD6uk3HbG4K1wmYIDHO/FMcVii/xI8+fJ+3zHfb+YyMpDVwMTotsrK\nU4o0xpATY9mq/R2ou1L+wVj8MWoS4U8y52VMNhHmk1NUnxTY5H7Ih2LtFxpG\nz8u1j5ilZa0ENbptY9eok6yPYt/EYsob16Kqf6/u5CiqUWV/wvA9y30T9LCm\n15C4foC0YX2MEuQpJwYhms58l9MAK811Z/W5l8SFuVCZAMFRVkpnFjQObIKA\nJlyLCQmRA+bL87hgFKFk/fC7zAaBbv/TsV20NWzDrD4Y0VWsVFGUiltojmT/\nPxtpXkkYpJTdOeF1aBUeV+AICgubSXAn6uYqbGtU9fwHhR8NJPP+NkStCWfH\nt86zm1FXmNTARCBplMYaxwzi+4iF0OdqQlMCmTXTbYSZ3CshocOPvalNEhhd\nw6mdJ5u3WB6WlneSEDAdiIW5bIuSB4Eryc3cCOsFWzAb3U5czNTwVUjwvIXa\nkWqueddNdviR0bt+npv4qhQB6YcsYn6sk+yfT6px8gNU4i4J9gwn3BOj/pEg\nZEN4+g+D0ZyDA7mOecWXWiKiMKVadzdjNS7yudAIC/tpkisQfU5EDIPy/QOw\ngw26ZROqMIKgjd1hi8iXWSQN4FKKIIsbCyhNyKgS7DMF36KEin3yPJsELxA4\nCwo3\r\n=9Ans\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBXTMrmk1xX9f1i4CKkK20LKIJR12TiMjLNxWCKM3evzAiA3ppMDCKTq2NayA5yYDue0uMfKkyE8hF1KjIBNrjrVUg=="}],"size":9102,"noattachment":false,"key":"/node-easy-cert/-/node-easy-cert-1.3.2.tgz"},"maintainers":[{"name":"codingfishman","email":"08fishman@gmail.com"},{"name":"ottomao","email":"ottomao@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-easy-cert_1.3.2_1576813399228_0.2765716478553939"},"_hasShrinkwrap":false,"readme":"node-easy-cert\n-------------------\n\n[![npm download][download-image]][download-url]\n\n[download-image]: https://img.shields.io/npm/dm/node-easy-cert.svg?style=flat-square\n[download-url]: https://npmjs.org/package/node-easy-cert\n\n\n## 用于管理自生成的HTTPS证书的插件\n本插件可以生成自签名的root证书，并基于该root证书，生成各个域名的HTTPS证书。\n\n## 使用方式\n```js\nconst CertManager = require('cert-manager');\n\nconst options = {\n  rootDirPath: '/the/full/path/of/the/dir', // default to /{USER_HOME}/{.node_easy_certs}/\n  // the default attrs of a generated cert, you can change it here\n  defaultCertAttrs: [\n    { name: 'countryName', value: 'CN' },\n    { name: 'organizationName', value: 'CertManager' },\n    { shortName: 'ST', value: 'SH' },\n    { shortName: 'OU', value: 'CertManager SSL' }\n  ]\n}\n\nconst crtMgr = new CertManager(options);\nconst rootOptions = {\n  commonName: 'theNameYouLike'\n};\n\ncrtMgr.generateRootCA(rootOptions);\n```\n## 配置项(可选)\n\n### rootDirPath\n证书目录的全路径，如果配置，优先级高于rootDirName\n\n## 证书生成目录\n默认情况下，证书都会生成在 `{USER_HOME}/.node_easy_certs/`。\n如果配置了`rootDirPath`, 那么所有的证书都会生成在该目录下。\n\n## 方法\n### generateRootCA(options, callback(error, keyPath, crtPath))\n在证书根目录下面生成根证书rootCA.crt 和 rootCA.key。生成后，请选择rootCA.crt,**安装并信任**，否则您的组件可能工作失败。\n\n#### 返回\n- 无\n\n#### 参数\n- options `object`\n  - options.commonName `string` `required`\n\n  rootCA的commonName，安装后，将会作为系统里面的证书名称显示在列表中\n  - options.overwrite `bool` `optional`\n\n  `default`: false\n  > 是否覆盖已经存在的rootCA，默认为false。在false的情形下，如果遇到已经存在的rootCA，会返回错误 `ROOT_CA_EXISTED` 并终止创建。\n\n- callback `function` `optional`\n\n  - error 如果发生错误，将放入error参数\n  - keyPath 生成好的rootCA.key的全路径\n  - crtPath 生成好的rootCA.crt的全路径\n\n#### 调用示例\n\n```js\nconst options = {\n  commonName: 'yourPreference'\n};\n\ncrtMgr.generateRootCA(options, (error, keyPath, crtPath) {\n  // 如果根证书已经存在，且没有设置overwrite为true，则需要捕获\n  if (error === 'ROOT_CA_EXISTED') {\n    // 处理当证书已经存在的情形\n  }\n\n  if(!error) {\n    // 证书需要被安装并信任，可以在此打开该目录并给出提示，也可以进行其他操作\n    const isWin = /^win/.test(process.platform);\n    const certDir = path.dirname(keyPath);\n    if(isWin){\n      exec(\"start .\",{ cwd : certDir });\n    }else{\n      exec(\"open .\",{ cwd : certDir });\n    }\n  }\n});\n```\n\n### getCertificate(hostname, callback([error, keyContent, crtContent]))\n获取指定域名下的证书的key和crt内容，如果证书还不存在，则会先创建该证书。\n\n> 证书的生成基于生成的rootCA根证书来签名，如果rootCA根证书还未创建，则会终止并抛出错误：`ROOT_CA_NOT_EXISTS`\n\n#### 返回\n- 无\n\n#### 参数\n- `hostname` `string`\n所要获取证书内容的hostname\n\n- `callback` `function`\n获取到内容后的回调函数，主要包含key的内容和crt的内容，如果获取过程中出现异常，则放入error变量中\n\n> 获取子域名的证书，要求已经存在根证书，否则会提示失败。组件会抛出对应的异常。您可以捕获并通过 `generateRootCA()`来生成根证书。**并安装并请信任该根证书**\n\n#### 调用实例\n```js\ncertManager.getCertificate('localhost', (error, keyContent, crtContent) => {\n\n  // 如果根证书还没有生成，需要先生成根证书\n  if (error === 'ROOT_CA_NOT_EXISTS') {\n    // handle the issue\n  }\n\n  // 正常操作\n  // ...\n});\n\n```\n\n### getRootDirPath()\n获取由当前cert-manager实例所管理的证书的根目录\n\n#### 返回\n- `string`\n  当前cert-manager实例所管理的证书所对应的根目录。默认为{USER_HOME}/.node_easy_certs/\n\n### getRootCAFilePath()\n获取根证书的全路径\n\n#### 返回\n- `string`\n根证书的全路径，如果根证书不存在，将返回空字符串\n\n### isRootCAFileExists()\n获取根证书是否存在的状态\n\n### ifRootCATrusted()\n检测RootCA是否已经被信任\n> 1.2.1 新增对Windows平台的支持\n\n#### 返回\n- `bool` 是否存在根证书\n\n### clearCerts()\n清除当前目录下所有的证书文件\n\n#### 返回\n- 无\n\n#### 参数\n- `callback`  `function`\n删除结束后的回调函数，如果删除过程中有错误，将会被放入error对象中\n\n# 错误码\n在运行过程中，会根据错误原因抛出指定错误码，包括如下\n\n| 错误码        | 释义           | 备注|\n| ------------- |:-------------:|:----------:|\n|ROOT_CA_NOT_EXISTS   |root根证书不存在。当我们执行的某个操作依赖于根证书，而根证书不存在时，就会抛出该异常。我们可以尝试生成根证书||\n|ROOT_CA_COMMON_NAME_UNSPECIFIED| commonName未设置。比如当我们调用`genearteRootCA()`时,commonName是必传的。||\n|ROOT_CA_EXISTED |rootCA 根证书已经存在。当我们重新生成证书，如果证书已经存在，会抛出该异常。|可以在调用`generateRootCA`时，传入 `option.overwirte=true`来覆盖|\n\n","publish_time":1576813399409,"_cnpm_publish_time":1576813399409,"dist-tags":{"latest":"1.3.3"}}