refactor: 修复几个小bug

master
xiaojunnuo 2021-01-03 23:33:51 +08:00
parent 9f371df372
commit b0def03790
4 changed files with 18 additions and 7 deletions

View File

@ -1,7 +1,11 @@
export class DnsProviderFactory {
static async createByType (type, options) {
const ProviderModule = await import('./impl/' + type + '.js')
const Provider = ProviderModule.default
return new Provider(options)
try {
const ProviderModule = await import('./impl/' + type + '.js')
const Provider = ProviderModule.default
return new Provider(options)
} catch (e) {
throw new Error('暂不支持此dnsProvider' + type, e)
}
}
}

View File

@ -92,6 +92,7 @@ export class Certd {
await this.writeCert(cert)
const certRet = await this.readCurrentCert()
certRet.isNew = true
return certRet
}
async createDnsProvider (options) {
@ -110,6 +111,9 @@ export class Certd {
async readCurrentCert () {
const cert = await this.certStore.readCert()
if (cert == null) {
return null
}
const { detail, expires } = this.getCrtDetail(cert.crt)
const domain = this.getMainDomain(this.options.cert.domains)
return {

View File

@ -39,9 +39,9 @@ export class CertStore {
const crtKey = this.buildKey(newDir, this.safetyDomain + '.crt')
const priKey = this.buildKey(newDir, this.safetyDomain + '.key')
const csrKey = this.buildKey(newDir, this.safetyDomain + '.csr')
await this.store.set(crtKey, this.formatCert(cert.crt))
await this.store.set(priKey, this.formatCert(cert.key))
await this.store.set(csrKey, cert.csr)
await this.store.set(crtKey, this.formatCert(cert.crt.toString()))
await this.store.set(priKey, this.formatCert(cert.key.toString()))
await this.store.set(csrKey, cert.csr.toString())
await this.store.link(newDir, this.currentRootPath)
@ -56,6 +56,9 @@ export class CertStore {
const priKey = this.buildKey(dir, this.safetyDomain + '.key')
const csrKey = this.buildKey(dir, this.safetyDomain + '.csr')
const crt = await this.store.get(crtKey)
if (crt == null) {
return null
}
const key = await this.store.get(priKey)
const csr = await this.store.get(csrKey)

@ -1 +1 @@
Subproject commit 1799074c0d63c75b98e98486bc979e099b1ad4f3
Subproject commit e384bc3c8e6ba95fc8dcab301c3cfaba8bb450f5