This commit is contained in:
AJ ONeal 2015-12-16 02:44:44 +00:00
parent db71fc5661
commit 9f5b52a7be
4 changed files with 34 additions and 7 deletions

View File

@ -1,8 +1,13 @@
/*!
* letiny-core
* Copyright(c) 2015 AJ ONeal <aj@daplie.com> https://daplie.com
* Apache-2.0 OR MIT (and hence also MPL 2.0)
*/
'use strict';
// It's good to have a place to store the certificates so you can, // It's good to have a place to store the certificates so you can,
// y'know, use them! :-) // y'know, use them! :-)
'use strict';
// you receive a hostname and must give back an object // you receive a hostname and must give back an object
// with a public cert chain and a private key // with a public cert chain and a private key

View File

@ -1,7 +1,12 @@
// Finally, you need an implementation of `challengeStore`: /*!
* letiny-core
* Copyright(c) 2015 AJ ONeal <aj@daplie.com> https://daplie.com
* Apache-2.0 OR MIT (and hence also MPL 2.0)
*/
'use strict'; 'use strict';
// Finally, you need an implementation of `challengeStore`:
// Note: // Note:
// key is the xxxx part of `/.well-known/acme-challenge/xxxx` // key is the xxxx part of `/.well-known/acme-challenge/xxxx`
// value is what is needs to be return the the requesting server // value is what is needs to be return the the requesting server

View File

@ -1,3 +1,8 @@
/*!
* letiny-core
* Copyright(c) 2015 AJ ONeal <aj@daplie.com> https://daplie.com
* Apache-2.0 OR MIT (and hence also MPL 2.0)
*/
'use strict'; 'use strict';
//var LeCore = require('letiny-core'); //var LeCore = require('letiny-core');
@ -24,9 +29,11 @@ init();
function init() { function init() {
getPrivateKeys(function () { getPrivateKeys(function () {
LeCore.getAcmeUrls(acmeDiscoveryUrl, function (urls) { console.log('Getting Acme Urls');
LeCore.getAcmeUrls(acmeDiscoveryUrl, function (err, urls) {
// in production choose LeCore.productionServerUrl // in production choose LeCore.productionServerUrl
console.log('Got Acme Urls', err, urls);
acmeUrls = urls; acmeUrls = urls;
runDemo(); runDemo();
@ -35,18 +42,21 @@ function init() {
} }
function getPrivateKeys() { function getPrivateKeys() {
console.log('Generating Account Keypair');
LeCore.leCrypto.generateRsaKeypair(2048, 65537, function (err, pems) { LeCore.leCrypto.generateRsaKeypair(2048, 65537, function (err, pems) {
accountPrivateKeyPem = pems.privateKeyPem; accountPrivateKeyPem = pems.privateKeyPem;
console.log('Generating Domain Keypair');
LeCore.leCrypto.generateRsaKeypair(2048, 65537, function (err, pems) { LeCore.leCrypto.generateRsaKeypair(2048, 65537, function (err, pems) {
domainPrivateKeyPem = pems.privateKeyPem; domainPrivateKeyPem = pems.privateKeyPem;
runDemo();
}); });
}); });
} }
function runDemo() { function runDemo() {
console.log('Registering New Account');
LeCore.registerNewAccount( LeCore.registerNewAccount(
{ newRegUrl: acmeUrls.newReg { newRegUrl: acmeUrls.newReg
, email: email , email: email
@ -66,6 +76,7 @@ function runDemo() {
console.log('[regr]'); console.log('[regr]');
console.log(regr); console.log(regr);
console.log('Registering New Certificate');
LeCore.getCertificate( LeCore.getCertificate(
{ domainPrivateKeyPem: domainPrivateKeyPem { domainPrivateKeyPem: domainPrivateKeyPem
, accountPrivateKeyPem: accountPrivateKeyPem , accountPrivateKeyPem: accountPrivateKeyPem

View File

@ -1,6 +1,12 @@
/*!
* letiny-core
* Copyright(c) 2015 AJ ONeal <aj@daplie.com> https://daplie.com
* Apache-2.0 OR MIT (and hence also MPL 2.0)
*/
'use strict';
// That will fail unless you have a webserver running on 80 and 443 (or 5001) // That will fail unless you have a webserver running on 80 and 443 (or 5001)
// to respond to `/.well-known/acme-challenge/xxxxxxxx` with the proper token // to respond to `/.well-known/acme-challenge/xxxxxxxx` with the proper token
'use strict';
module.exports.init = function (deps) { module.exports.init = function (deps) {
var tls = require('tls'); var tls = require('tls');