mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: configurable cert key type #264
This commit is contained in:
parent
a095c88fd2
commit
22d62e420b
12 changed files with 115 additions and 28 deletions
|
@ -74,6 +74,7 @@ func renew(certModel *model.Cert) {
|
|||
ServerName: certModel.Domains,
|
||||
ChallengeMethod: certModel.ChallengeMethod,
|
||||
DNSCredentialID: certModel.DnsCredentialID,
|
||||
KeyType: certModel.GetKeyType(),
|
||||
}
|
||||
|
||||
// errChan will be closed inside IssueCert
|
||||
|
|
|
@ -32,9 +32,10 @@ const (
|
|||
)
|
||||
|
||||
type ConfigPayload struct {
|
||||
ServerName []string `json:"server_name"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
DNSCredentialID int `json:"dns_credential_id"`
|
||||
ServerName []string `json:"server_name"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
DNSCredentialID int `json:"dns_credential_id"`
|
||||
KeyType certcrypto.KeyType `json:"key_type"`
|
||||
}
|
||||
|
||||
func IssueCert(payload *ConfigPayload, logChan chan string, errChan chan error) {
|
||||
|
@ -93,7 +94,7 @@ func IssueCert(payload *ConfigPayload, logChan chan string, errChan chan error)
|
|||
}
|
||||
}
|
||||
|
||||
config.Certificate.KeyType = certcrypto.RSA2048
|
||||
config.Certificate.KeyType = payload.KeyType
|
||||
|
||||
l.Println("[INFO] [Nginx UI] Creating client facilitates communication with the CA server")
|
||||
// A client facilitates communication with the CA server.
|
||||
|
|
15
internal/validation/key_type.go
Normal file
15
internal/validation/key_type.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package validation
|
||||
|
||||
import (
|
||||
"github.com/go-acme/lego/v4/certcrypto"
|
||||
val "github.com/go-playground/validator/v10"
|
||||
)
|
||||
|
||||
func autoCertKeyType(fl val.FieldLevel) bool {
|
||||
switch certcrypto.KeyType(fl.Field().String()) {
|
||||
case certcrypto.RSA2048, certcrypto.RSA3072, certcrypto.RSA4096,
|
||||
certcrypto.EC256, certcrypto.EC384:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
|
@ -42,5 +42,11 @@ func Init() {
|
|||
logger.Fatal(err)
|
||||
}
|
||||
|
||||
err = v.RegisterValidation("auto_cert_key_type", autoCertKeyType)
|
||||
|
||||
if err != nil {
|
||||
logger.Fatal(err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue