Skip to content

Commit

Permalink
refactor(Server): move certificate generation to it's own file
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed Aug 27, 2018
1 parent 1896fcf commit 4789ac3
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions lib/util/createCertificate.js
@@ -0,0 +1,65 @@
'use strict';

/* eslint-disable
space-before-function-paren
*/
const selfsigned = require('selfsigned');

function createCertificate (attrs) {
return selfsigned.generate(attrs, {
algorithm: 'sha256',
days: 30,
keySize: 2048,
extensions: [
{
name: 'basicConstraints',
cA: true
},
{
name: 'keyUsage',
keyCertSign: true,
digitalSignature: true,
nonRepudiation: true,
keyEncipherment: true,
dataEncipherment: true
},
{
name: 'subjectAltName',
altNames: [
{
// type 2 is DNS
type: 2,
value: 'localhost'
},
{
type: 2,
value: 'localhost.localdomain'
},
{
type: 2,
value: 'lvh.me'
},
{
type: 2,
value: '*.lvh.me'
},
{
type: 2,
value: '[::1]'
},
{
// type 7 is IP
type: 7,
ip: '127.0.0.1'
},
{
type: 7,
ip: 'fe80::1'
}
]
}
]
});
}

module.exports = createCertificate;

0 comments on commit 4789ac3

Please sign in to comment.