forked from hackedcorp/hackedvault
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-cert.js
More file actions
26 lines (21 loc) · 761 Bytes
/
generate-cert.js
File metadata and controls
26 lines (21 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const selfsigned = require('selfsigned');
const fs = require('fs');
const path = require('path');
const attrs = [
{ name: 'commonName', value: 'localhost' },
{ name: 'countryName', value: 'US' },
{ name: 'organizationName', value: 'HackedVault Dev' },
{ name: 'organizationalUnitName', value: 'Development' }
];
const pems = selfsigned.generate(attrs, {
algorithm: 'sha256',
days: 365,
keySize: 2048,
});
const certDir = path.join(__dirname, 'certs');
if (!fs.existsSync(certDir)) {
fs.mkdirSync(certDir);
}
fs.writeFileSync(path.join(certDir, 'private-key.pem'), pems.private);
fs.writeFileSync(path.join(certDir, 'public-cert.pem'), pems.cert);
console.log('SSL certificates generated successfully in ./certs directory');