You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
617 B

3 years ago
'use strict'
3 years ago
const selfCert = require('self-cert')
3 years ago
async function buildCertificate () {
// "global" is used in here because "t.context" is only supported by "t.beforeEach" and "t.afterEach"
// For the test case which execute this code which will be using `t.before` and it can reduce the
// number of times executing it.
if (!global.context || !global.context.cert || !global.context.key) {
3 years ago
const certs = selfCert({
expires: new Date(Date.now() + 86400000)
})
3 years ago
global.context = {
3 years ago
cert: certs.certificate,
key: certs.privateKey
3 years ago
}
}
}
module.exports = { buildCertificate }