mirror of https://github.com/bjdgyc/anylink.git
修复检查证书文件是否存在失败的bug
This commit is contained in:
parent
5dc8114167
commit
19e99b7648
|
@ -69,8 +69,7 @@ func CreatCert(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
config := &dbdata.SettingLetsEncrypt{}
|
config := &dbdata.SettingLetsEncrypt{}
|
||||||
err = json.Unmarshal(body, config)
|
if err := json.Unmarshal(body, config); err != nil {
|
||||||
if err != nil {
|
|
||||||
RespError(w, RespInternalErr, err)
|
RespError(w, RespInternalErr, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,8 +261,12 @@ func (c *LeGoClient) SaveCert() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseCert() (*tls.Certificate, *time.Time, error) {
|
func ParseCert() (*tls.Certificate, *time.Time, error) {
|
||||||
os.Stat(base.Cfg.CertFile)
|
_, errCert := os.Stat(base.Cfg.CertFile)
|
||||||
os.Stat(base.Cfg.CertKey)
|
_, errKey := os.Stat(base.Cfg.CertKey)
|
||||||
|
if os.IsNotExist(errCert) || os.IsNotExist(errKey) {
|
||||||
|
PrivateCert()
|
||||||
|
|
||||||
|
}
|
||||||
cert, err := tls.LoadX509KeyPair(base.Cfg.CertFile, base.Cfg.CertKey)
|
cert, err := tls.LoadX509KeyPair(base.Cfg.CertFile, base.Cfg.CertKey)
|
||||||
if err != nil || errors.Is(err, os.ErrNotExist) {
|
if err != nil || errors.Is(err, os.ErrNotExist) {
|
||||||
PrivateCert()
|
PrivateCert()
|
||||||
|
|
Loading…
Reference in New Issue