mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 04:10:27 +08:00
40 lines
895 B
Go
40 lines
895 B
Go
package certs
|
|
|
|
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
|
|
}) {
|
|
certResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{SslCertId: params.CertId})
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
|
|
if len(certResp.SslCertJSON) == 0 {
|
|
this.NotFound("sslCert", params.CertId)
|
|
return
|
|
}
|
|
|
|
certConfig := &sslconfigs.SSLCertConfig{}
|
|
err = json.Unmarshal(certResp.SslCertJSON, certConfig)
|
|
if err != nil {
|
|
this.ErrorPage(err)
|
|
return
|
|
}
|
|
_, _ = this.Write(certConfig.CertData)
|
|
}
|