2020-11-24 17:36:42 +08:00
|
|
|
package certs
|
2020-09-30 17:46:38 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ViewCertAction struct {
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *ViewCertAction) Init() {
|
|
|
|
|
this.Nav("", "", "")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *ViewCertAction) RunGet(params struct {
|
|
|
|
|
CertId int64
|
|
|
|
|
}) {
|
2020-12-18 21:18:35 +08:00
|
|
|
certResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{SslCertId: params.CertId})
|
2020-09-30 17:46:38 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 21:18:35 +08:00
|
|
|
if len(certResp.SslCertJSON) == 0 {
|
2020-11-25 21:19:07 +08:00
|
|
|
this.NotFound("sslCert", params.CertId)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 17:46:38 +08:00
|
|
|
certConfig := &sslconfigs.SSLCertConfig{}
|
2020-12-18 21:18:35 +08:00
|
|
|
err = json.Unmarshal(certResp.SslCertJSON, certConfig)
|
2020-09-30 17:46:38 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.Write(certConfig.CertData)
|
|
|
|
|
}
|