feat(self-signed): expose days option

This commit is contained in:
Julien Fontanet
2020-07-30 11:17:45 +02:00
parent a11e9fe04e
commit ea8f319f45
3 changed files with 18 additions and 4 deletions

View File

@@ -19,7 +19,14 @@ Installation of the [npm package](https://npmjs.org/package/@xen-orchestra/self-
```js
import { genSelfSigned } from '@xen-orchestra/self-signed'
console.log(await genSelfSigned())
console.log(
await genSelfSigned({
// Number of days this certificate will be valid.
//
// Default: 360
days: 600,
})
)
// {
// cert: '-----BEGIN CERTIFICATE-----\n' +
// // content…

View File

@@ -1,7 +1,14 @@
```js
import { genSelfSigned } from '@xen-orchestra/self-signed'
console.log(await genSelfSigned())
console.log(
await genSelfSigned({
// Number of days this certificate will be valid.
//
// Default: 360
days: 600,
})
)
// {
// cert: '-----BEGIN CERTIFICATE-----\n' +
// // content…

View File

@@ -10,12 +10,12 @@ const openssl = (cmd, args, { input, ...opts } = {}) =>
}
})
exports.genSelfSignedCert = async () => {
exports.genSelfSignedCert = async ({ days = 360 } = {}) => {
const key = await openssl('genrsa', ['2048'])
return {
cert: await openssl(
'req',
['-batch', '-new', '-key', '-', '-x509', '-days', '360', '-nodes'],
['-batch', '-new', '-key', '-', '-x509', '-days', String(days), '-nodes'],
{
input: key,
}