Delete certs from redis
This commit is contained in:
+10
-1
@@ -14,4 +14,13 @@ async function getCert(host){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {getCert};
|
async function deleteCert(host){
|
||||||
|
try{
|
||||||
|
console.log('looking for', host);
|
||||||
|
return JSON.parse(await client.DEL(`${host}:latest`));
|
||||||
|
}catch(error){
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {getCert, deleteCert};
|
||||||
|
|||||||
+5
-13
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const Table = require('.');
|
const Table = require('.');
|
||||||
const {Domain} = require('.').models;
|
const {Domain} = require('.').models;
|
||||||
|
const {deleteCert} = require('./cert');
|
||||||
const ModelPs = require('../utils/model_pubsub');
|
const ModelPs = require('../utils/model_pubsub');
|
||||||
|
|
||||||
const tldExtract = require('tld-extract').parse_host;
|
const tldExtract = require('tld-extract').parse_host;
|
||||||
@@ -82,9 +83,6 @@ class Host extends Table{
|
|||||||
|
|
||||||
static async create(data, ...args){
|
static async create(data, ...args){
|
||||||
try{
|
try{
|
||||||
|
|
||||||
console.log('host create data', data.challengeType, data.challengeType === 'DNS-01-wildcard')
|
|
||||||
|
|
||||||
// Validate requested host is valid host and domain
|
// Validate requested host is valid host and domain
|
||||||
if(data.challengeType === 'DNS-01-wildcard'){
|
if(data.challengeType === 'DNS-01-wildcard'){
|
||||||
data.is_wildcard = true;
|
data.is_wildcard = true;
|
||||||
@@ -95,33 +93,25 @@ class Host extends Table{
|
|||||||
// Validate requested host has a valid wildcard parent
|
// Validate requested host has a valid wildcard parent
|
||||||
if(data.challengeType === 'wildcardChild'){
|
if(data.challengeType === 'wildcardChild'){
|
||||||
let parentHost = await this.lookUp(data.host);
|
let parentHost = await this.lookUp(data.host);
|
||||||
console.log('parentHost:', parentHost)
|
|
||||||
if(parentHost.is_wildcard){
|
if(parentHost.is_wildcard){
|
||||||
data.wildcard_parent = parentHost.host;
|
data.wildcard_parent = parentHost.host;
|
||||||
}else{
|
}else{
|
||||||
throw new Error(`No parent wild card for ${data.host}`);
|
throw new Error(`No parent wild card for ${data.host}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Host create here 102')
|
|
||||||
|
|
||||||
// Create the new host entry
|
// Create the new host entry
|
||||||
let out = await super.create(data, ...args);
|
let out = await super.create(data, ...args);
|
||||||
console.log('Host create here 106')
|
|
||||||
|
|
||||||
// Update the lookup table to reflect new host
|
// Update the lookup table to reflect new host
|
||||||
await this.buildLookUpObj();
|
await this.buildLookUpObj();
|
||||||
|
|
||||||
console.log('Host create here 111')
|
|
||||||
// Fire the request for the wild card cert
|
// Fire the request for the wild card cert
|
||||||
// This is "back ground" job, await is intentionally missing
|
// This is "back ground" job, await is intentionally missing
|
||||||
if(data.challengeType === 'DNS-01-wildcard') out.createWildcardCert();
|
if(data.challengeType === 'DNS-01-wildcard') out.createWildcardCert();
|
||||||
|
|
||||||
console.log('Host create here 111')
|
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
} catch(error){
|
} catch(error){
|
||||||
console.log(error)
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,11 +129,10 @@ class Host extends Table{
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createWildcardCert(){
|
async createWildcardCert(){
|
||||||
console.log('createWildcardCert here')
|
console.log('createWildcardCert', this.domain)
|
||||||
if(!this.host.startsWith('*.')) throw new Error('not wild card');
|
if(!this.host.startsWith('*.')) throw new Error('not wild card');
|
||||||
|
|
||||||
try{
|
try{
|
||||||
console.log('createWildcardCert here in try')
|
|
||||||
let host = this;
|
let host = this;
|
||||||
|
|
||||||
await host.update({
|
await host.update({
|
||||||
@@ -246,6 +235,7 @@ class Host extends Table{
|
|||||||
|
|
||||||
async checkWildcardForRenew(){
|
async checkWildcardForRenew(){
|
||||||
try{
|
try{
|
||||||
|
console.log(`Checking ${this.host}`);
|
||||||
if(this.is_wildcard && Date.now() > this.wildcard_expires - (30 * 24 * 60 * 60 * 1000)){
|
if(this.is_wildcard && Date.now() > this.wildcard_expires - (30 * 24 * 60 * 60 * 1000)){
|
||||||
this.createWildcardCert();
|
this.createWildcardCert();
|
||||||
}
|
}
|
||||||
@@ -257,6 +247,7 @@ class Host extends Table{
|
|||||||
|
|
||||||
static async checkWildcardForRenew(){
|
static async checkWildcardForRenew(){
|
||||||
try{
|
try{
|
||||||
|
console.log('checkWildcardForRenew here', this)
|
||||||
for(let host of await this.listDetail()){
|
for(let host of await this.listDetail()){
|
||||||
host.createWildcardCert();
|
host.createWildcardCert();
|
||||||
}
|
}
|
||||||
@@ -283,6 +274,7 @@ class Host extends Table{
|
|||||||
let out = await super.remove(...args);
|
let out = await super.remove(...args);
|
||||||
await Host.buildLookUpObj();
|
await Host.buildLookUpObj();
|
||||||
await this.bustCache(this.host);
|
await this.bustCache(this.host);
|
||||||
|
await deleteCert(this.domain);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
} catch(error){
|
} catch(error){
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
$('tr.jq-repeat-hosts').each(function(idx, el){
|
$('tr.jq-repeat-hosts').each(function(idx, el){
|
||||||
$(el).removeClass('table-warning');
|
$(el).removeClass('table-warning');
|
||||||
});
|
});
|
||||||
$.scope.editHost.remove();
|
$.scope.editHost.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostEditOpen(btn, host){
|
function hostEditOpen(btn, host){
|
||||||
|
|||||||
Reference in New Issue
Block a user