mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-18 02:19:51 +00:00
Merge branch 'feat-add-netsh-preset' of github.com:LeoChen98/certimate into LeoChen98-feat-add-netsh-preset
This commit is contained in:
commit
261c6f6956
@ -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 = "<your-pfx-path>" # PFX 文件路径
|
||||
$pfxPassword = "<your-pfx-password>" # PFX 密码
|
||||
$ipaddr = "<your-binding-ip>" # 绑定 IP,“0.0.0.0”表示所有 IP 绑定,可填入域名。
|
||||
$port = "<your-binding-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
|
||||
<DropdownMenuItem onClick={() => handleUsePresetScript("binding_iis")}>
|
||||
{t("domain.deployment.form.shell_preset_scripts.option.binding_iis.label")}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => handleUsePresetScript("binding_netsh")}>
|
||||
{t("domain.deployment.form.shell_preset_scripts.option.binding_netsh.label")}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
|
@ -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",
|
||||
|
@ -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 名称",
|
||||
|
Loading…
x
Reference in New Issue
Block a user