From 67ca7e3097173d982e7a31b6fa5dae14f4228d7b Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Tue, 29 Oct 2024 21:43:20 +0800 Subject: [PATCH 1/9] feat: add netsh preset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增本地Windows下使用netsh绑定证书的预设 --- ui/src/components/certimate/DeployToLocal.tsx | 34 +++++++++++++++++++ ui/src/i18n/locales/en/nls.domain.json | 1 + ui/src/i18n/locales/zh/nls.domain.json | 1 + 3 files changed, 36 insertions(+) diff --git a/ui/src/components/certimate/DeployToLocal.tsx b/ui/src/components/certimate/DeployToLocal.tsx index 672cf52c..bd808f82 100644 --- a/ui/src/components/certimate/DeployToLocal.tsx +++ b/ui/src/components/certimate/DeployToLocal.tsx @@ -199,6 +199,37 @@ $binding = Get-WebBinding -Name "$siteName" -Protocol "https" -Port $port -IPAdd # 绑定 SSL 证书 $binding.AddSslCertificate($thumbprint, "My") # 删除目录下的证书文件 +Remove-Item -Path "$pfxPath" -Force + `.trim(); + }); + setDeploy(newData); + } + break; + + case "binding_netsh": + { + const newData = produce(data, (draft) => { + draft.config ??= {}; + draft.config.shell = "powershell"; + draft.config.command = ` +# 请将以下变量替换为实际值 +$pfxPath = "" # PFX 文件路径 +$pfxPassword = "" # PFX 密码 +$ipaddr = "" # 绑定 IP,“0.0.0.0”表示所有 IP 绑定,可填入域名。 +$port = "" # 绑定端口 + +$addr = $ipaddr + ":" + $port + +# 导入证书到本地计算机的个人存储区 +$cert = Import-PfxCertificate -FilePath "$pfxPath" -CertStoreLocation Cert:\LocalMachine\My -Password (ConvertTo-SecureString -String "$pfxPassword" -AsPlainText -Force) -Exportable +# 获取 Thumbprint +$thumbprint = $cert.Thumbprint +# 检测端口是否绑定证书,如绑定则删除绑定 +$isExist = netsh http show sslcert ipport=$addr +if ($isExist -like "*$addr*"){ netsh http delete sslcert ipport=$addr } +# 绑定到端口 +netsh http add sslcert ipport=$addr certhash=$thumbprint +# 删除目录下的证书文件 Remove-Item -Path "$pfxPath" -Force `.trim(); }); @@ -425,6 +456,9 @@ Remove-Item -Path "$pfxPath" -Force handleUsePresetScript("binding_iis")}> {t("domain.deployment.form.shell_preset_scripts.option.binding_iis.label")} + handleUsePresetScript("binding_netsh")}> + {t("domain.deployment.form.shell_preset_scripts.option.binding_netsh.label")} + diff --git a/ui/src/i18n/locales/en/nls.domain.json b/ui/src/i18n/locales/en/nls.domain.json index 06e78c6d..3ea712ab 100644 --- a/ui/src/i18n/locales/en/nls.domain.json +++ b/ui/src/i18n/locales/en/nls.domain.json @@ -146,6 +146,7 @@ "domain.deployment.form.shell_preset_scripts.trigger": "Use Preset Scripts", "domain.deployment.form.shell_preset_scripts.option.reload_nginx.label": "Bash - Reload Nginx", "domain.deployment.form.shell_preset_scripts.option.binding_iis.label": "PowerShell - Binding IIS", + "domain.deployment.form.shell_preset_scripts.option.binding_netsh.label": "PowerShell - Binding netsh(Windows)", "domain.deployment.form.k8s_namespace.label": "Namespace", "domain.deployment.form.k8s_namespace.placeholder": "Please enter namespace", "domain.deployment.form.k8s_secret_name.label": "Secret Name", diff --git a/ui/src/i18n/locales/zh/nls.domain.json b/ui/src/i18n/locales/zh/nls.domain.json index 7ccf94ba..1df7795b 100644 --- a/ui/src/i18n/locales/zh/nls.domain.json +++ b/ui/src/i18n/locales/zh/nls.domain.json @@ -143,6 +143,7 @@ "domain.deployment.form.shell_preset_scripts.trigger": "使用预设脚本", "domain.deployment.form.shell_preset_scripts.option.reload_nginx.label": "Bash - 重启 nginx", "domain.deployment.form.shell_preset_scripts.option.binding_iis.label": "PowerShell - 导入并绑定到 IIS(需管理员权限)", + "domain.deployment.form.shell_preset_scripts.option.binding_netsh.label": "PowerShell - 导入并绑定到netsh(需管理员权限)", "domain.deployment.form.k8s_namespace.label": "命名空间", "domain.deployment.form.k8s_namespace.placeholder": "请输入 K8S 命名空间", "domain.deployment.form.k8s_secret_name.label": "Secret 名称", From 61a4fd8657e153e247bc19ebb11afffb3434cf55 Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Wed, 30 Oct 2024 07:04:05 +0800 Subject: [PATCH 2/9] v0.2.10 --- ui/src/domain/version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/domain/version.ts b/ui/src/domain/version.ts index d1500737..2d8b0c59 100644 --- a/ui/src/domain/version.ts +++ b/ui/src/domain/version.ts @@ -1 +1 @@ -export const version = "Certimate v0.2.9"; +export const version = "Certimate v0.2.10"; From 16967c4ab1d96e04b8816b1d72c932eae4a0f27b Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Wed, 30 Oct 2024 09:31:51 +0800 Subject: [PATCH 3/9] fix tencent cdn deploy --- internal/deployer/tencent_cdn.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/deployer/tencent_cdn.go b/internal/deployer/tencent_cdn.go index 26c9c252..566d5b9b 100644 --- a/internal/deployer/tencent_cdn.go +++ b/internal/deployer/tencent_cdn.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "strings" + "golang.org/x/exp/slices" cdn "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdn/v20180606" @@ -111,10 +112,10 @@ func (d *TencentCDNDeployer) deploy(certId string) error { request.InstanceIdList = common.StringPtrs(list) } else { // 否则直接使用传入的域名 deployed, _ := d.isDomainDeployed(certId, domain) - if(deployed){ + if deployed { d.infos = append(d.infos, "域名已部署") return nil - }else{ + } else { request.InstanceIdList = common.StringPtrs([]string{domain}) } } @@ -150,7 +151,7 @@ func (d *TencentCDNDeployer) getDomainList(certId string) ([]string, error) { domains := make([]string, 0) for _, domain := range response.Response.Domains { domainStr := *domain - if(slices.Contains(deployedDomains, domainStr)){ + if !slices.Contains(deployedDomains, domainStr) { domains = append(domains, domainStr) } } @@ -160,7 +161,7 @@ func (d *TencentCDNDeployer) getDomainList(certId string) ([]string, error) { func (d *TencentCDNDeployer) isDomainDeployed(certId, domain string) (bool, error) { deployedDomains, err := d.getDeployedDomainList(certId) - if(err != nil){ + if err != nil { return false, err } From 55b77fdf5cdd305fcd43e1e2d6098b8188c8e1ae Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Wed, 30 Oct 2024 11:03:41 +0800 Subject: [PATCH 4/9] Fix the issue where the deployment type could not be selected --- ui/index.html | 2 +- ui/src/components/certimate/AccessEditDialog.tsx | 11 ++++++++++- ui/src/components/certimate/DeployEditDialog.tsx | 7 ++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ui/index.html b/ui/index.html index 1b46f3b3..c1604c3c 100644 --- a/ui/index.html +++ b/ui/index.html @@ -6,7 +6,7 @@ Certimate - Your Trusted SSL Automation Partner - +
diff --git a/ui/src/components/certimate/AccessEditDialog.tsx b/ui/src/components/certimate/AccessEditDialog.tsx index afa41da8..afb23068 100644 --- a/ui/src/components/certimate/AccessEditDialog.tsx +++ b/ui/src/components/certimate/AccessEditDialog.tsx @@ -195,7 +195,16 @@ const AccessEditDialog = ({ trigger, op, data, className }: AccessEditProps) => } return ( - + { + if (openState) { + document.body.style.pointerEvents = "auto"; + } + setOpen(openState); + }} + open={open} + modal={false} + > {trigger} diff --git a/ui/src/components/certimate/DeployEditDialog.tsx b/ui/src/components/certimate/DeployEditDialog.tsx index 3e4804b9..6db96012 100644 --- a/ui/src/components/certimate/DeployEditDialog.tsx +++ b/ui/src/components/certimate/DeployEditDialog.tsx @@ -179,7 +179,12 @@ const DeployEditDialog = ({ trigger, deployConfig, onSave }: DeployEditDialogPro > {trigger} - + { + event.preventDefault(); + }} + > {t("domain.deployment.tab")} From c1cefe0e7f7b8e2df7102641b83b97b68ea21aa6 Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Wed, 30 Oct 2024 11:07:59 +0800 Subject: [PATCH 5/9] v0.2.11 --- ui/src/domain/version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/domain/version.ts b/ui/src/domain/version.ts index 2d8b0c59..45cff52f 100644 --- a/ui/src/domain/version.ts +++ b/ui/src/domain/version.ts @@ -1 +1 @@ -export const version = "Certimate v0.2.10"; +export const version = "Certimate v0.2.11"; From b97d77c8488b67e52b492fd42afac2fa58052764 Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Wed, 30 Oct 2024 11:57:16 +0800 Subject: [PATCH 6/9] Fix the issue where long domain names or titles overlap the next column. --- ui/src/domain/settings.ts | 12 +++++++++--- ui/src/pages/access/Access.tsx | 4 +++- ui/src/pages/dashboard/Dashboard.tsx | 9 ++------- ui/src/pages/domains/Home.tsx | 10 +++------- ui/src/pages/history/History.tsx | 9 ++------- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/ui/src/domain/settings.ts b/ui/src/domain/settings.ts index 798c4e86..114fc8ac 100644 --- a/ui/src/domain/settings.ts +++ b/ui/src/domain/settings.ts @@ -26,7 +26,13 @@ export type NotifyChannels = { mail?: NotifyChannelMail; }; -export type NotifyChannel = NotifyChannelDingTalk | NotifyChannelLark | NotifyChannelTelegram | NotifyChannelWebhook | NotifyChannelServerChan | NotifyChannelMail; +export type NotifyChannel = + | NotifyChannelDingTalk + | NotifyChannelLark + | NotifyChannelTelegram + | NotifyChannelWebhook + | NotifyChannelServerChan + | NotifyChannelMail; export type NotifyChannelDingTalk = { accessToken: string; @@ -60,8 +66,8 @@ export type NotifyChannelMail = { receiverAddresses: string; smtpHostAddr: string; smtpHostPort: string; - username:string; - password:string; + username: string; + password: string; enabled: boolean; }; diff --git a/ui/src/pages/access/Access.tsx b/ui/src/pages/access/Access.tsx index 6fb3cd66..f079703d 100644 --- a/ui/src/pages/access/Access.tsx +++ b/ui/src/pages/access/Access.tsx @@ -117,7 +117,9 @@ const Access = () => { className="flex flex-col sm:flex-row text-secondary-foreground border-b dark:border-stone-500 sm:p-2 hover:bg-muted/50 text-sm" key={access.id} > -
{access.name}
+
+
{access.name}
+
{t(accessProvidersMap.get(access.configType)?.name || "")}
diff --git a/ui/src/pages/dashboard/Dashboard.tsx b/ui/src/pages/dashboard/Dashboard.tsx index ff655b98..7de1d16a 100644 --- a/ui/src/pages/dashboard/Dashboard.tsx +++ b/ui/src/pages/dashboard/Dashboard.tsx @@ -180,13 +180,8 @@ const Dashboard = () => { key={deployment.id} className="flex flex-col sm:flex-row text-secondary-foreground border-b dark:border-stone-500 sm:p-2 hover:bg-muted/50 text-sm" > -
- {deployment.expand.domain?.domain.split(";").map((domain: string) => ( - <> - {domain} -
- - ))} +
+ {deployment.expand.domain?.domain.split(";").map((domain: string) =>
{domain}
)}
diff --git a/ui/src/pages/domains/Home.tsx b/ui/src/pages/domains/Home.tsx index 4e66714c..a2d6411c 100644 --- a/ui/src/pages/domains/Home.tsx +++ b/ui/src/pages/domains/Home.tsx @@ -201,12 +201,9 @@ const Home = () => { className="flex flex-col sm:flex-row text-secondary-foreground border-b dark:border-stone-500 sm:p-2 hover:bg-muted/50 text-sm" key={domain.id} > -
- {domain.domain.split(";").map((item) => ( - <> - {item} -
- +
+ {domain.domain.split(";").map((domain: string) => ( +
{domain}
))}
@@ -340,4 +337,3 @@ const Home = () => { }; export default Home; - diff --git a/ui/src/pages/history/History.tsx b/ui/src/pages/history/History.tsx index e0a47186..5bdaec53 100644 --- a/ui/src/pages/history/History.tsx +++ b/ui/src/pages/history/History.tsx @@ -75,13 +75,8 @@ const History = () => { key={deployment.id} className="flex flex-col sm:flex-row text-secondary-foreground border-b dark:border-stone-500 sm:p-2 hover:bg-muted/50 text-sm" > -
- {deployment.expand.domain?.domain.split(";").map((domain: string) => ( - <> - {domain} -
- - ))} +
+ {deployment.expand.domain?.domain.split(";").map((domain: string) =>
{domain}
)}
From b4599df6c6194116497e0ea00a3b600c337ace4d Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Wed, 30 Oct 2024 12:28:59 +0800 Subject: [PATCH 7/9] code format --- ui/src/components/certimate/DeployToLocal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/components/certimate/DeployToLocal.tsx b/ui/src/components/certimate/DeployToLocal.tsx index bd808f82..ae60e75d 100644 --- a/ui/src/components/certimate/DeployToLocal.tsx +++ b/ui/src/components/certimate/DeployToLocal.tsx @@ -206,7 +206,7 @@ Remove-Item -Path "$pfxPath" -Force } break; - case "binding_netsh": + case "binding_netsh": { const newData = produce(data, (draft) => { draft.config ??= {}; @@ -221,7 +221,7 @@ $port = "" # 绑定端口 $addr = $ipaddr + ":" + $port # 导入证书到本地计算机的个人存储区 -$cert = Import-PfxCertificate -FilePath "$pfxPath" -CertStoreLocation Cert:\LocalMachine\My -Password (ConvertTo-SecureString -String "$pfxPassword" -AsPlainText -Force) -Exportable +$cert = Import-PfxCertificate -FilePath "$pfxPath" -CertStoreLocation Cert:\\LocalMachine\\My -Password (ConvertTo-SecureString -String "$pfxPassword" -AsPlainText -Force) -Exportable # 获取 Thumbprint $thumbprint = $cert.Thumbprint # 检测端口是否绑定证书,如绑定则删除绑定 From d833f4b5ff05a31a9915e04a598c8d8353838203 Mon Sep 17 00:00:00 2001 From: yoan <536464346@qq.com> Date: Wed, 30 Oct 2024 16:08:32 +0800 Subject: [PATCH 8/9] fix cos region validate --- ui/src/components/certimate/DeployToTencentCOS.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/certimate/DeployToTencentCOS.tsx b/ui/src/components/certimate/DeployToTencentCOS.tsx index 7fcb5e2a..d6edd925 100644 --- a/ui/src/components/certimate/DeployToTencentCOS.tsx +++ b/ui/src/components/certimate/DeployToTencentCOS.tsx @@ -97,7 +97,7 @@ const DeployToTencentCOS = () => { onChange={(e) => { const temp = e.target.value; - const resp = bucketSchema.safeParse(temp); + const resp = regionSchema.safeParse(temp); if (!resp.success) { setError({ ...error, From 1f52eaca01a4a5692fd25ee18d00e840c6baa6f1 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Wed, 30 Oct 2024 17:09:11 +0800 Subject: [PATCH 9/9] fix: tencent cos ui locales loss --- ui/src/components/certimate/DeployToTencentCOS.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/components/certimate/DeployToTencentCOS.tsx b/ui/src/components/certimate/DeployToTencentCOS.tsx index 7fcb5e2a..b1d3d737 100644 --- a/ui/src/components/certimate/DeployToTencentCOS.tsx +++ b/ui/src/components/certimate/DeployToTencentCOS.tsx @@ -79,11 +79,11 @@ const DeployToTencentCOS = () => { }); const regionSchema = z.string().regex(/^ap-[a-z]+$/, { - message: t("domain.deployment.form.cos_region.placeholder"), + message: t("domain.deployment.form.tencent_cos_region.placeholder"), }); const bucketSchema = z.string().regex(/^.+-\d+$/, { - message: t("domain.deployment.form.cos_bucket.placeholder"), + message: t("domain.deployment.form.tencent_cos_bucket.placeholder"), }); return (