From 1462cddd1eb347b7ff238286b5c977b29a0591ec Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 11 Nov 2025 00:32:43 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=94=AF=E6=8C=81letencrypt=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83=EF=BC=8C=E6=94=AF=E6=8C=81IP?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/acme-client/src/index.js | 3 +++ packages/core/acme-client/types/index.d.ts | 3 +++ .../plugin-cert/src/plugin/cert-plugin/acme.ts | 16 +++++----------- .../plugin-cert/src/plugin/cert-plugin/index.ts | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/core/acme-client/src/index.js b/packages/core/acme-client/src/index.js index a40d9544..561c5195 100644 --- a/packages/core/acme-client/src/index.js +++ b/packages/core/acme-client/src/index.js @@ -21,6 +21,9 @@ export const directory = { staging: 'https://acme-staging-v02.api.letsencrypt.org/directory', production: 'https://acme-v02.api.letsencrypt.org/directory', }, + letsencrypt_staging: { + production: 'https://acme-staging-v02.api.letsencrypt.org/directory', + }, zerossl: { staging: 'https://acme.zerossl.com/v2/DV90', production: 'https://acme.zerossl.com/v2/DV90', diff --git a/packages/core/acme-client/types/index.d.ts b/packages/core/acme-client/types/index.d.ts index 5c81057a..fd33fb42 100644 --- a/packages/core/acme-client/types/index.d.ts +++ b/packages/core/acme-client/types/index.d.ts @@ -108,6 +108,9 @@ export const directory: { staging: string, production: string }, + letsencrypt_staging: { + production: string + }, zerossl: { staging: string, production: string diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts index 74ba8173..74322522 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/acme.ts @@ -50,7 +50,7 @@ export type CertInfo = { one?: string; p7b?: string; }; -export type SSLProvider = "letsencrypt" | "google" | "zerossl" | "sslcom"; +export type SSLProvider = "letsencrypt" | "google" | "zerossl" | "sslcom" | "letsencrypt_staging"; export type PrivateKeyType = "rsa_1024" | "rsa_2048" | "rsa_3072" | "rsa_4096" | "ec_256" | "ec_384" | "ec_521"; type AcmeServiceOptions = { userContext: IContext; @@ -111,7 +111,7 @@ export class AcmeService { await this.userContext.setObj(this.buildAccountKey(email), conf); } - async getAcmeClient(email: string, isTest = false): Promise { + async getAcmeClient(email: string): Promise { const mappings = {}; if (this.sslProvider === "letsencrypt") { mappings["acme-v02.api.letsencrypt.org"] = this.options.reverseProxy || "le.px.certd.handfree.work"; @@ -128,12 +128,7 @@ export class AcmeService { await this.saveAccountConfig(email, conf); this.logger.info(`创建新的Accountkey:${email}`); } - let directoryUrl = ""; - if (isTest) { - directoryUrl = acme.directory[this.sslProvider].staging; - } else { - directoryUrl = acme.directory[this.sslProvider].production; - } + const directoryUrl = acme.directory[this.sslProvider].production; if (this.options.useMappingProxy) { urlMapping.enabled = true; } else { @@ -327,13 +322,12 @@ export class AcmeService { domainsVerifyPlan?: DomainsVerifyPlan; httpUploader?: any; csrInfo: any; - isTest?: boolean; privateKeyType?: string; profile?: string; preferredChain?: string; }): Promise { - const { email, isTest, csrInfo, dnsProvider, domainsVerifyPlan, profile, preferredChain } = options; - const client: acme.Client = await this.getAcmeClient(email, isTest); + const { email, csrInfo, dnsProvider, domainsVerifyPlan, profile, preferredChain } = options; + const client: acme.Client = await this.getAcmeClient(email); let domains = options.domains; const encodingDomains = []; diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts index 8811ccd3..53263187 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/index.ts @@ -137,6 +137,7 @@ export class CertApplyPlugin extends CertApplyBasePlugin { { value: "google", label: "Google(免费)", icon: "flat-color-icons:google" }, { value: "zerossl", label: "ZeroSSL(免费)", icon: "emojione:digit-zero" }, { value: "sslcom", label: "SSL.com(仅主域名和www免费)", icon: "la:expeditedssl" }, + { value: "letsencrypt_staging", label: "Let's Encrypt测试环境(IP证书)", icon: "simple-icons:letsencrypt" }, ], }, helper: "Let's Encrypt:申请最简单\nGoogle:大厂光环,兼容性好,仅首次需要翻墙获取EAB授权\nZeroSSL:需要EAB授权,无需翻墙\nSSL.com:仅主域名和www免费,必须设置CAA记录", @@ -412,7 +413,7 @@ export class CertApplyPlugin extends CertApplyBasePlugin { async onInit() { let eab: EabAccess = null; - if (this.sslProvider && this.sslProvider !== "letsencrypt") { + if (this.sslProvider && !this.sslProvider.startsWith("letsencrypt")) { if (this.sslProvider === "google" && this.googleAccessId) { this.logger.info("当前正在使用 google服务账号授权获取EAB"); const googleAccess = await this.getAccess(this.googleAccessId); @@ -495,7 +496,6 @@ export class CertApplyPlugin extends CertApplyBasePlugin { dnsProvider, domainsVerifyPlan, csrInfo, - isTest: false, privateKeyType: this.privateKeyType, profile: this.certProfile, preferredChain: this.preferredChain,