mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-12 02:45:49 +02:00
enhance: auto obtain cert
This commit is contained in:
parent
e260860adc
commit
e9d26ded1c
4 changed files with 70 additions and 74 deletions
|
@ -29,14 +29,10 @@ const columns = [{
|
|||
},
|
||||
search: true
|
||||
}, {
|
||||
title: () => $gettext('Domain'),
|
||||
dataIndex: 'domain',
|
||||
title: () => $gettext('Config Name'),
|
||||
dataIndex: 'filename',
|
||||
sorter: true,
|
||||
pithy: true,
|
||||
edit: {
|
||||
type: input
|
||||
},
|
||||
search: true
|
||||
pithy: true
|
||||
}, {
|
||||
title: () => $gettext('Auto Cert'),
|
||||
dataIndex: 'auto_cert',
|
||||
|
|
|
@ -364,6 +364,7 @@ func AddDomainToAutoCert(c *gin.Context) {
|
|||
}
|
||||
|
||||
err = certModel.Updates(&model.Cert{
|
||||
Name: name,
|
||||
AutoCert: model.AutoCertEnabled,
|
||||
})
|
||||
|
||||
|
|
|
@ -89,5 +89,9 @@ func (c *Cert) Updates(n *Cert) error {
|
|||
}
|
||||
|
||||
func (c *Cert) Remove() error {
|
||||
if c.Filename == "" {
|
||||
return db.Delete(c).Error
|
||||
}
|
||||
|
||||
return db.Where("filename", c.Filename).Delete(c).Error
|
||||
}
|
||||
|
|
|
@ -81,12 +81,7 @@ func AutoObtain() {
|
|||
continue
|
||||
}
|
||||
|
||||
if certModel.SSLCertificatePath == "" {
|
||||
errLog.Exit(confName, errors.New("ssl_certificate_path is empty, "+
|
||||
"try to reopen auto-cert for this config:"+confName))
|
||||
continue
|
||||
}
|
||||
|
||||
if certModel.SSLCertificatePath != "" {
|
||||
cert, err := GetCertInfo(certModel.SSLCertificatePath)
|
||||
if err != nil {
|
||||
errLog.Push("get cert info", err)
|
||||
|
@ -97,7 +92,7 @@ func AutoObtain() {
|
|||
if time.Now().Sub(cert.NotBefore).Hours()/24 < 7 {
|
||||
continue
|
||||
}
|
||||
//
|
||||
}
|
||||
// after 1 mo, reissue certificate
|
||||
logChan := make(chan string, 1)
|
||||
errChan := make(chan error, 1)
|
||||
|
@ -108,7 +103,7 @@ func AutoObtain() {
|
|||
go handleIssueCertLogChan(logChan)
|
||||
|
||||
// block, unless errChan closed
|
||||
for err = range errChan {
|
||||
for err := range errChan {
|
||||
errLog.Push("issue cert", err)
|
||||
}
|
||||
// store error log to db
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue