【新增】宝塔dns

【修复】查看证书于下载证书内容不一致
【修复】多个ca无法选中
【修复】创建中间证书私有ca加密算法没有默认继承
【调整】下载自签证书附带pfx
This commit is contained in:
v-me-50
2025-09-17 15:35:18 +08:00
parent e16d0b748b
commit 5b7245a78d
4 changed files with 49 additions and 3 deletions

View File

@@ -162,6 +162,10 @@ func DownloadCert(c *gin.Context) {
public.FailMsg(c, err.Error())
return
}
if certData == nil {
public.FailMsg(c, "证书不存在")
return
}
// 构建 zip 包(内存中)
buf := new(bytes.Buffer)
@@ -213,6 +217,32 @@ func DownloadCert(c *gin.Context) {
}
}
if certData["algorithm"] == "ecdsa" || certData["algorithm"] == "rsa" {
// cert.pfx
pfxPassword := "allinssl"
pfxData, err := public.PEMToPFX(certStr, keyStr, pfxPassword)
if err == nil && len(pfxData) > 0 {
pfxWriter, err := zipWriter.Create("IIS/cert.pfx")
if err != nil {
public.FailMsg(c, err.Error())
return
}
if _, err := pfxWriter.Write(pfxData); err != nil {
public.FailMsg(c, err.Error())
return
}
txtWriter, err := zipWriter.Create("IIS/passwd.txt")
if err != nil {
public.FailMsg(c, err.Error())
return
}
if _, err := txtWriter.Write([]byte(pfxPassword)); err != nil {
public.FailMsg(c, err.Error())
return
}
}
}
// 关闭 zipWriter
if err := zipWriter.Close(); err != nil {
public.FailMsg(c, err.Error())