fix(core): now creating certs all right
This commit is contained in:
parent
651ef6d281
commit
223a47c997
8
package-lock.json
generated
8
package-lock.json
generated
@ -69,6 +69,14 @@
|
|||||||
"ansi-256-colors": "^1.1.0"
|
"ansi-256-colors": "^1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@pushrocks/smartdelay": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@pushrocks/smartdelay/-/smartdelay-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-4xf6tMKwZcxBynKgXrM4SQKgeASfRvx43LUmR5DkStp26ZHAsarCXUdKJS6y8QIPygEOTOCP8we97JAcCzBuMg==",
|
||||||
|
"requires": {
|
||||||
|
"@pushrocks/smartpromise": "^2.0.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@pushrocks/smartfile": {
|
"@pushrocks/smartfile": {
|
||||||
"version": "6.0.6",
|
"version": "6.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.6.tgz",
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/umbrellazone/smartacme#README",
|
"homepage": "https://gitlab.com/umbrellazone/smartacme#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@pushrocks/smartdelay": "^2.0.2",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
"acme-v2": "^1.2.0",
|
"acme-v2": "^1.2.0",
|
||||||
"rsa-compat": "^1.5.1"
|
"rsa-compat": "^1.5.1"
|
||||||
|
@ -8,6 +8,7 @@ tap.test('should create a valid instance of SmartAcme' , async () => {
|
|||||||
smartAcmeInstance = new smartacme.SmartAcme();
|
smartAcmeInstance = new smartacme.SmartAcme();
|
||||||
await smartAcmeInstance.init()
|
await smartAcmeInstance.init()
|
||||||
console.log(smartAcmeInstance.directoryUrls);
|
console.log(smartAcmeInstance.directoryUrls);
|
||||||
|
await smartAcmeInstance.getCertificateForDomain('bleu.de');
|
||||||
})
|
})
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
@ -15,33 +15,75 @@ const acme = require('acme-v2').ACME.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// don't try to validate challenges locally
|
// don't try to validate challenges locally
|
||||||
skipChallengeTest: false
|
skipChallengeTest: true
|
||||||
});
|
});
|
||||||
|
|
||||||
import { KeyPair } from './smartacme.classes.keypair';
|
import { KeyPair } from './smartacme.classes.keypair';
|
||||||
|
import * as plugins from './smartacme.plugins';
|
||||||
|
const rsa = require('rsa-compat').RSA;
|
||||||
|
|
||||||
export class SmartAcme {
|
export class SmartAcme {
|
||||||
keyPair: KeyPair;
|
domainKeyPair: KeyPair;
|
||||||
|
accountKeyPair: KeyPair;
|
||||||
|
accountData: any;
|
||||||
directoryUrls: any;
|
directoryUrls: any;
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
// get directory url
|
// get directory url
|
||||||
this.directoryUrls = await acme.init('https://acme-staging-v02.api.letsencrypt.org/directory');
|
this.directoryUrls = await acme.init('https://acme-staging-v02.api.letsencrypt.org/directory');
|
||||||
|
|
||||||
// create keyPair
|
// create keyPairs
|
||||||
this.keyPair = await KeyPair.generateFresh();
|
this.domainKeyPair = await KeyPair.generateFresh();
|
||||||
|
this.accountKeyPair = await KeyPair.generateFresh();
|
||||||
|
|
||||||
// get account
|
// get account
|
||||||
const registrationData = await acme.accounts.create({
|
const registrationData = await acme.accounts
|
||||||
|
.create({
|
||||||
email: 'domains@lossless.org', // valid email (server checks MX records)
|
email: 'domains@lossless.org', // valid email (server checks MX records)
|
||||||
accountKeypair: this.keyPair.rsaKeyPair,
|
accountKeypair: this.accountKeyPair.rsaKeyPair,
|
||||||
agreeToTerms: async tosUrl => {
|
agreeToTerms: async tosUrl => {
|
||||||
return tosUrl;
|
return tosUrl;
|
||||||
}
|
}
|
||||||
}).catch(e => {
|
})
|
||||||
|
.catch(e => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
});
|
});
|
||||||
|
this.accountData = registrationData;
|
||||||
|
}
|
||||||
|
|
||||||
console.log(registrationData);
|
async getCertificateForDomain(domain) {
|
||||||
|
const result = await acme.certificates
|
||||||
|
.create({
|
||||||
|
domainKeypair: this.domainKeyPair.rsaKeyPair,
|
||||||
|
accountKeypair: this.accountKeyPair.rsaKeyPair,
|
||||||
|
domains: ['bleu.de'],
|
||||||
|
challengeType: 'dns-01',
|
||||||
|
|
||||||
|
setChallenge: async (hostname, key, val, cb) => {
|
||||||
|
console.log('set challenge');
|
||||||
|
console.log(hostname);
|
||||||
|
//console.log(key);
|
||||||
|
//console.log(val);
|
||||||
|
const dnsKey = rsa.utils.toWebsafeBase64(
|
||||||
|
require('crypto')
|
||||||
|
.createHash('sha256')
|
||||||
|
.update(val)
|
||||||
|
.digest('base64')
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(dnsKey);
|
||||||
|
await plugins.smartdelay.delayFor(20000);
|
||||||
|
console.log('ready!');
|
||||||
|
cb();
|
||||||
|
}, // return Promise
|
||||||
|
removeChallenge: async (hostname, key) => {
|
||||||
|
console.log('removing challenge');
|
||||||
|
return;
|
||||||
|
} // return Promise
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
console.log(e);
|
||||||
|
}); // returns Promise<pems={ privkey (key), cert, chain (ca) }>
|
||||||
|
console.log(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
smartpromise
|
smartpromise,
|
||||||
|
smartdelay
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user