feat(self-signed): expose days option
This commit is contained in:
@@ -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…
|
||||
|
||||
@@ -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…
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user