File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ /* eslint-disable
4
+ space-before-function-paren
5
+ */
6
+ const selfsigned = require ( 'selfsigned' ) ;
7
+
8
+ function createCertificate ( attrs ) {
9
+ return selfsigned . generate ( attrs , {
10
+ algorithm : 'sha256' ,
11
+ days : 30 ,
12
+ keySize : 2048 ,
13
+ extensions : [
14
+ {
15
+ name : 'basicConstraints' ,
16
+ cA : true
17
+ } ,
18
+ {
19
+ name : 'keyUsage' ,
20
+ keyCertSign : true ,
21
+ digitalSignature : true ,
22
+ nonRepudiation : true ,
23
+ keyEncipherment : true ,
24
+ dataEncipherment : true
25
+ } ,
26
+ {
27
+ name : 'subjectAltName' ,
28
+ altNames : [
29
+ {
30
+ // type 2 is DNS
31
+ type : 2 ,
32
+ value : 'localhost'
33
+ } ,
34
+ {
35
+ type : 2 ,
36
+ value : 'localhost.localdomain'
37
+ } ,
38
+ {
39
+ type : 2 ,
40
+ value : 'lvh.me'
41
+ } ,
42
+ {
43
+ type : 2 ,
44
+ value : '*.lvh.me'
45
+ } ,
46
+ {
47
+ type : 2 ,
48
+ value : '[::1]'
49
+ } ,
50
+ {
51
+ // type 7 is IP
52
+ type : 7 ,
53
+ ip : '127.0.0.1'
54
+ } ,
55
+ {
56
+ type : 7 ,
57
+ ip : 'fe80::1'
58
+ }
59
+ ]
60
+ }
61
+ ]
62
+ } ) ;
63
+ }
64
+
65
+ module . exports = createCertificate ;
You can’t perform that action at this time.
0 commit comments