mirror of
https://github.com/certd/certd.git
synced 2026-06-26 13:17:33 +08:00
chore(cert): add md5 hash naming and duplicate cert handling
1. 新增buildCertName方法的useHash参数,使用域名列表MD5哈希作为证书名后缀避免时间戳重复 2. 为asiaisp上传证书添加重复证书检测逻辑,已存在时直接复用已有证书
This commit is contained in:
@@ -280,9 +280,14 @@ export class CertReader {
|
||||
return `${prefix}_${domain}_${timeStr}.${suffix}`;
|
||||
}
|
||||
|
||||
buildCertName(prefix: string = "") {
|
||||
buildCertName(prefix: string = "", useHash: boolean = false) {
|
||||
let domain = this.getMainDomain();
|
||||
domain = domain.replaceAll(".", "_").replaceAll("*", "_");
|
||||
if (useHash) {
|
||||
const domains = JSON.stringify(this.getAllDomains());
|
||||
const hash = cryptoLib.createHash("md5").update(domains).digest("hex").slice(0, 16);
|
||||
return `${prefix}_${domain}_${hash}`;
|
||||
}
|
||||
return `${prefix}_${domain}_${dayjs().format("YYYYMMDDHHmmssSSS")}`;
|
||||
}
|
||||
|
||||
@@ -293,7 +298,7 @@ export class CertReader {
|
||||
return name + "_" + dayjs().format("YYYYMMDDHHmmssSSS");
|
||||
}
|
||||
|
||||
static buildCertName(cert: CertInfo) {
|
||||
return new CertReader(cert).buildCertName();
|
||||
static buildCertName(cert: CertInfo, useHash: boolean = false) {
|
||||
return new CertReader(cert).buildCertName("", useHash);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user