feat: configurable cert key type #264

This commit is contained in:
Jacky 2024-02-13 14:15:02 +08:00
parent a095c88fd2
commit 22d62e420b
12 changed files with 115 additions and 28 deletions

View 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
}

View file

@ -42,5 +42,11 @@ func Init() {
logger.Fatal(err)
}
err = v.RegisterValidation("auto_cert_key_type", autoCertKeyType)
if err != nil {
logger.Fatal(err)
}
return
}