-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathletsencrypt-test.js
More file actions
executable file
·53 lines (45 loc) · 1.22 KB
/
letsencrypt-test.js
File metadata and controls
executable file
·53 lines (45 loc) · 1.22 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env node
var ACME = '/home/wallet/public_html/.well-known/acme-challenge';
var HOME = './ssl';
var domains = [ 'wallet.nchain.ir' ];
var G_LOCK = require('greenlock');
var mkdirp = require('mkdirp');
var store = require('le-store-certbot').create({
configDir: HOME,
privkeyPath: ':configDir/ssl.key/:hostname.key',
fullchainPath: ':configDir/:hostname.full_ca_bundle',
certPath: ':configDir/ssl.crt/:hostname.crt',
chainPath: ':configDir/:hostname.ca_bundle',
webrootPath: ACME,
debug: false
});
var challenge = require('le-challenge-fs').create({
webrootPath: ACME,
loopbackPort: 5001,
loopbackTimeout: 10000,
debug: false
});
var greenlock = G_LOCK.create({
version: 'draft-12',
server: 'https://acme-v02.api.letsencrypt.org/directory',
store: store,
challenges: {
'http-01': challenge
},
challengeType: 'http-01'
});
mkdirp.sync(HOME + '/ssl.key');
mkdirp.sync(HOME + '/ssl.crt');
greenlock.check({ domains: domains })
.then(ok => {
if (ok) return;
greenlock.register({
domains: domains,
email: 'amouha@visionsoba.com',
agreeTos: true,
rsaKeySize: 2048,
challengeType: 'http-01'
})
.then(() => console.log('success'))
.catch(err => console.error(err));
});