mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
perf: 证书到期剩余天数进度条根据实际证书有效期计算 (#528) nicheng-he
* Create FUNDING.yml * Update FUNDING.yml * Update README.md * Update README.md * Update README.md * Update README.md * Update README_en.md * 证书到期剩余天数进度条根据实际证书时间计算 --------- Co-authored-by: greper <xiaojunnuo@qq.com>
This commit is contained in:
@@ -30,6 +30,9 @@ export class CertInfoEntity {
|
||||
@Column({ name: 'cert_provider', comment: '证书颁发机构' })
|
||||
certProvider: string;
|
||||
|
||||
@Column({ name: 'effective_time', comment: '生效时间' })
|
||||
effectiveTime: number;
|
||||
|
||||
@Column({ name: 'expires_time', comment: '过期时间' })
|
||||
expiresTime: number;
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ export class SiteInfoEntity {
|
||||
@Column({ name: 'cert_provider', comment: '证书颁发机构', length: 100 })
|
||||
certProvider: string;
|
||||
|
||||
@Column({ name: 'cert_effective_time', comment: '证书生效时间' })
|
||||
certEffectiveTime: number;
|
||||
@Column({ name: 'cert_expires_time', comment: '证书到期时间' })
|
||||
certExpiresTime: number;
|
||||
@Column({ name: 'last_check_time', comment: '上次检查时间' })
|
||||
|
||||
@@ -164,6 +164,7 @@ export class CertInfoService extends BaseService<CertInfoEntity> {
|
||||
bean.domains = domains.join(',');
|
||||
bean.domain = domains[0];
|
||||
bean.domainCount = domains.length;
|
||||
bean.effectiveTime = certReader.effective;
|
||||
bean.expiresTime = certReader.expires;
|
||||
bean.certProvider = certReader.detail.issuer.commonName;
|
||||
bean.userId = userId
|
||||
|
||||
@@ -134,6 +134,7 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||
if (!certi) {
|
||||
throw new Error("没有发现证书");
|
||||
}
|
||||
const effective = certi.valid_from;
|
||||
const expires = certi.valid_to;
|
||||
const allDomains = certi.subjectaltname?.replaceAll("DNS:", "").split(",") || [];
|
||||
const mainDomain = certi.subject?.CN;
|
||||
@@ -149,12 +150,13 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||
certDomains: domains.join(","),
|
||||
certStatus: status,
|
||||
certProvider: issuer,
|
||||
certEffectiveTime: dayjs(effective).valueOf(),
|
||||
certExpiresTime: dayjs(expires).valueOf(),
|
||||
lastCheckTime: dayjs().valueOf(),
|
||||
error: null,
|
||||
checkStatus: "ok"
|
||||
};
|
||||
logger.info(`测试站点成功:id=${updateData.id},site=${site.name},expiresTime=${updateData.certExpiresTime}`)
|
||||
logger.info(`测试站点成功:id=${updateData.id},site=${site.name},certEffectiveTime=${updateData.certEffectiveTime},expiresTime=${updateData.certExpiresTime}`)
|
||||
if (site.ipCheck) {
|
||||
delete updateData.checkStatus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user