Fix getCertByApplication()

This commit is contained in:
Yang Luo
2023-05-18 16:32:43 +08:00
parent 9f084a0799
commit 04eaad1c80
2 changed files with 30 additions and 2 deletions

View File

@ -134,6 +134,24 @@ func getCert(owner string, name string) *Cert {
}
}
func getCertByName(name string) *Cert {
if name == "" {
return nil
}
cert := Cert{Name: name}
existed, err := adapter.Engine.Get(&cert)
if err != nil {
panic(err)
}
if existed {
return &cert
} else {
return nil
}
}
func GetCert(id string) *Cert {
owner, name := util.GetOwnerAndNameFromId(id)
return getCert(owner, name)
@ -189,7 +207,7 @@ func (p *Cert) GetId() string {
func getCertByApplication(application *Application) *Cert {
if application.Cert != "" {
return getCert("admin", application.Cert)
return getCertByName(application.Cert)
} else {
return GetDefaultCert()
}