mirror of
https://github.com/allinssl/allinssl.git
synced 2025-12-15 09:55:37 +08:00
【新增】宝塔dns
【修复】查看证书于下载证书内容不一致 【修复】多个ca无法选中 【修复】创建中间证书私有ca加密算法没有默认继承 【调整】下载自签证书附带pfx
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user