AJ ONeal
5 years ago
15 changed files with 2508 additions and 2508 deletions
File diff suppressed because it is too large
@ -1,95 +1,95 @@ |
|||||
var accountKeypair = await Keypairs.generate({ kty: accKty }); |
var accountKeypair = await Keypairs.generate({ kty: accKty }); |
||||
if (config.debug) { |
if (config.debug) { |
||||
console.info('Account Key Created'); |
console.info('Account Key Created'); |
||||
console.info(JSON.stringify(accountKeypair, null, 2)); |
console.info(JSON.stringify(accountKeypair, null, 2)); |
||||
console.info(); |
console.info(); |
||||
console.info(); |
console.info(); |
||||
} |
} |
||||
|
|
||||
var account = await acme.accounts.create({ |
var account = await acme.accounts.create({ |
||||
agreeToTerms: agree, |
agreeToTerms: agree, |
||||
// TODO detect jwk/pem/der?
|
// TODO detect jwk/pem/der?
|
||||
accountKeypair: { privateKeyJwk: accountKeypair.private }, |
accountKeypair: { privateKeyJwk: accountKeypair.private }, |
||||
subscriberEmail: config.email |
subscriberEmail: config.email |
||||
}); |
}); |
||||
|
|
||||
// TODO top-level agree
|
// TODO top-level agree
|
||||
function agree(tos) { |
function agree(tos) { |
||||
if (config.debug) { |
if (config.debug) { |
||||
console.info('Agreeing to Terms of Service:'); |
console.info('Agreeing to Terms of Service:'); |
||||
console.info(tos); |
console.info(tos); |
||||
console.info(); |
console.info(); |
||||
console.info(); |
console.info(); |
||||
} |
} |
||||
agreed = true; |
agreed = true; |
||||
return Promise.resolve(tos); |
return Promise.resolve(tos); |
||||
} |
} |
||||
if (config.debug) { |
if (config.debug) { |
||||
console.info('New Subscriber Account'); |
console.info('New Subscriber Account'); |
||||
console.info(JSON.stringify(account, null, 2)); |
console.info(JSON.stringify(account, null, 2)); |
||||
console.info(); |
console.info(); |
||||
console.info(); |
console.info(); |
||||
} |
} |
||||
if (!agreed) { |
if (!agreed) { |
||||
throw new Error('Failed to ask the user to agree to terms'); |
throw new Error('Failed to ask the user to agree to terms'); |
||||
} |
} |
||||
|
|
||||
var certKeypair = await Keypairs.generate({ kty: srvKty }); |
var certKeypair = await Keypairs.generate({ kty: srvKty }); |
||||
var pem = await Keypairs.export({ |
var pem = await Keypairs.export({ |
||||
jwk: certKeypair.private, |
jwk: certKeypair.private, |
||||
encoding: 'pem' |
encoding: 'pem' |
||||
}); |
}); |
||||
if (config.debug) { |
if (config.debug) { |
||||
console.info('Server Key Created'); |
console.info('Server Key Created'); |
||||
console.info('privkey.jwk.json'); |
console.info('privkey.jwk.json'); |
||||
console.info(JSON.stringify(certKeypair, null, 2)); |
console.info(JSON.stringify(certKeypair, null, 2)); |
||||
// This should be saved as `privkey.pem`
|
// This should be saved as `privkey.pem`
|
||||
console.info(); |
console.info(); |
||||
console.info('privkey.' + srvKty.toLowerCase() + '.pem:'); |
console.info('privkey.' + srvKty.toLowerCase() + '.pem:'); |
||||
console.info(pem); |
console.info(pem); |
||||
console.info(); |
console.info(); |
||||
} |
} |
||||
|
|
||||
// 'subject' should be first in list
|
// 'subject' should be first in list
|
||||
var domains = randomDomains(rnd); |
var domains = randomDomains(rnd); |
||||
if (config.debug) { |
if (config.debug) { |
||||
console.info('Get certificates for random domains:'); |
console.info('Get certificates for random domains:'); |
||||
console.info( |
console.info( |
||||
domains |
domains |
||||
.map(function(puny) { |
.map(function(puny) { |
||||
var uni = punycode.toUnicode(puny); |
var uni = punycode.toUnicode(puny); |
||||
if (puny !== uni) { |
if (puny !== uni) { |
||||
return puny + ' (' + uni + ')'; |
return puny + ' (' + uni + ')'; |
||||
} |
} |
||||
return puny; |
return puny; |
||||
}) |
}) |
||||
.join('\n') |
.join('\n') |
||||
); |
); |
||||
console.info(); |
console.info(); |
||||
} |
} |
||||
|
|
||||
// Create CSR
|
// Create CSR
|
||||
var csrDer = await CSR.csr({ |
var csrDer = await CSR.csr({ |
||||
jwk: certKeypair.private, |
jwk: certKeypair.private, |
||||
domains: domains, |
domains: domains, |
||||
encoding: 'der' |
encoding: 'der' |
||||
}); |
}); |
||||
var csr = Enc.bufToUrlBase64(csrDer); |
var csr = Enc.bufToUrlBase64(csrDer); |
||||
var csrPem = PEM.packBlock({ |
var csrPem = PEM.packBlock({ |
||||
type: 'CERTIFICATE REQUEST', |
type: 'CERTIFICATE REQUEST', |
||||
bytes: csrDer /* { jwk: jwk, domains: opts.domains } */ |
bytes: csrDer /* { jwk: jwk, domains: opts.domains } */ |
||||
}); |
}); |
||||
if (config.debug) { |
if (config.debug) { |
||||
console.info('Certificate Signing Request'); |
console.info('Certificate Signing Request'); |
||||
console.info(csrPem); |
console.info(csrPem); |
||||
console.info(); |
console.info(); |
||||
} |
} |
||||
|
|
||||
var results = await acme.certificates.create({ |
var results = await acme.certificates.create({ |
||||
account: account, |
account: account, |
||||
accountKeypair: { privateKeyJwk: accountKeypair.private }, |
accountKeypair: { privateKeyJwk: accountKeypair.private }, |
||||
csr: csr, |
csr: csr, |
||||
domains: domains, |
domains: domains, |
||||
challenges: challenges, // must be implemented
|
challenges: challenges, // must be implemented
|
||||
customerEmail: null |
customerEmail: null |
||||
}); |
}); |
||||
|
@ -1,53 +1,53 @@ |
|||||
{ |
{ |
||||
"name": "@root/greenlock", |
"name": "@root/greenlock", |
||||
"version": "3.0.17", |
"version": "3.0.17", |
||||
"description": "The easiest Let's Encrypt client for Node.js and Browsers", |
"description": "The easiest Let's Encrypt client for Node.js and Browsers", |
||||
"homepage": "https://rootprojects.org/greenlock/", |
"homepage": "https://rootprojects.org/greenlock/", |
||||
"main": "greenlock.js", |
"main": "greenlock.js", |
||||
"browser": {}, |
"browser": {}, |
||||
"files": [ |
"files": [ |
||||
"*.js", |
"*.js", |
||||
"lib", |
"lib", |
||||
"bin", |
"bin", |
||||
"dist" |
"dist" |
||||
], |
], |
||||
"scripts": { |
"scripts": { |
||||
"build": "nodex bin/bundle.js", |
"build": "nodex bin/bundle.js", |
||||
"lint": "jshint lib bin", |
"lint": "jshint lib bin", |
||||
"test": "node server.js", |
"test": "node server.js", |
||||
"start": "node server.js" |
"start": "node server.js" |
||||
}, |
}, |
||||
"repository": { |
"repository": { |
||||
"type": "git", |
"type": "git", |
||||
"url": "https://git.rootprojects.org/root/greenlock.js.git" |
"url": "https://git.rootprojects.org/root/greenlock.js.git" |
||||
}, |
}, |
||||
"keywords": [ |
"keywords": [ |
||||
"Let's Encrypt", |
"Let's Encrypt", |
||||
"ACME", |
"ACME", |
||||
"browser", |
"browser", |
||||
"EC", |
"EC", |
||||
"RSA", |
"RSA", |
||||
"CSR", |
"CSR", |
||||
"greenlock", |
"greenlock", |
||||
"VanillaJS", |
"VanillaJS", |
||||
"ZeroSSL" |
"ZeroSSL" |
||||
], |
], |
||||
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)", |
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)", |
||||
"license": "MPL-2.0", |
"license": "MPL-2.0", |
||||
"dependencies": { |
"dependencies": { |
||||
"@root/acme": "^3.0.8", |
"@root/acme": "^3.0.8", |
||||
"@root/csr": "^0.8.1", |
"@root/csr": "^0.8.1", |
||||
"@root/keypairs": "^0.9.0", |
"@root/keypairs": "^0.9.0", |
||||
"@root/mkdirp": "^1.0.0", |
"@root/mkdirp": "^1.0.0", |
||||
"@root/request": "^1.3.10", |
"@root/request": "^1.3.10", |
||||
"acme-http-01-standalone": "^3.0.5", |
"acme-http-01-standalone": "^3.0.5", |
||||
"cert-info": "^1.5.1", |
"cert-info": "^1.5.1", |
||||
"greenlock-manager-fs": "^3.0.1", |
"greenlock-manager-fs": "^3.0.1", |
||||
"greenlock-store-fs": "^3.2.0", |
"greenlock-store-fs": "^3.2.0", |
||||
"safe-replace": "^1.1.0" |
"safe-replace": "^1.1.0" |
||||
}, |
}, |
||||
"devDependencies": { |
"devDependencies": { |
||||
"dotenv": "^8.2.0", |
"dotenv": "^8.2.0", |
||||
"punycode": "^1.4.1" |
"punycode": "^1.4.1" |
||||
} |
} |
||||
} |
} |
||||
|
Loading…
Reference in new issue