mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-04-18 17:35:19 +08:00
证书在上传时检查有效期
This commit is contained in:
@@ -70,13 +70,13 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
certConfigJSON := certConfigResp.SslCertJSON
|
||||
var certConfigJSON = certConfigResp.SslCertJSON
|
||||
if len(certConfigJSON) == 0 {
|
||||
this.NotFound("cert", params.CertId)
|
||||
return
|
||||
}
|
||||
|
||||
certConfig := &sslconfigs.SSLCertConfig{}
|
||||
var certConfig = &sslconfigs.SSLCertConfig{}
|
||||
err = json.Unmarshal(certConfigJSON, certConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -99,7 +99,6 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if params.CertFile != nil {
|
||||
certConfig.CertData, err = params.CertFile.Read()
|
||||
if err != nil {
|
||||
@@ -132,6 +131,13 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
this.Fail("证书格式错误:无法读取到证书有效期")
|
||||
}
|
||||
|
||||
if certConfig.TimeBeginAt < 0 {
|
||||
this.Fail("证书校验错误:有效期开始时间过小,不能小于1970年1月1日")
|
||||
}
|
||||
if certConfig.TimeEndAt < 0 {
|
||||
this.Fail("证书校验错误:有效期结束时间过小,不能小于1970年1月1日")
|
||||
}
|
||||
|
||||
// 保存
|
||||
_, err = this.RPC().SSLCertRPC().UpdateSSLCert(this.AdminContext(), &pb.UpdateSSLCertRequest{
|
||||
SslCertId: params.CertId,
|
||||
|
||||
Reference in New Issue
Block a user