mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: support not-only Let's Encrypt service #16
This commit is contained in:
parent
3e90b838fd
commit
49b41d6eb7
6 changed files with 60 additions and 57 deletions
|
@ -2,6 +2,9 @@ package cert
|
|||
|
||||
import (
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/logger"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/0xJacky/Nginx-UI/query"
|
||||
"github.com/go-acme/lego/v4/certcrypto"
|
||||
)
|
||||
|
||||
|
@ -9,9 +12,26 @@ type ConfigPayload struct {
|
|||
ServerName []string `json:"server_name"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
DNSCredentialID int `json:"dns_credential_id"`
|
||||
ACMEUserID int `json:"acme_user_id"`
|
||||
KeyType certcrypto.KeyType `json:"key_type"`
|
||||
}
|
||||
|
||||
func (c *ConfigPayload) GetACMEUser() (user *model.AcmeUser, err error) {
|
||||
u := query.AcmeUser
|
||||
// if acme_user_id == 0, use default user
|
||||
if c.ACMEUserID == 0 {
|
||||
return GetDefaultACMEUser()
|
||||
}
|
||||
// use the acme_user_id to get the acme user
|
||||
user, err = u.Where(u.ID.Eq(c.ACMEUserID)).First()
|
||||
// if acme_user not exist, use default user
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return GetDefaultACMEUser()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *ConfigPayload) GetKeyType() certcrypto.KeyType {
|
||||
return helper.GetKeyType(c.KeyType)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue