diff options
author | Pascal <pascalgn@users.noreply.github.com> | 2020-03-26 06:16:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-25 23:16:12 -0600 |
commit | 5c55e5d53fcd5f60921dc477a4eb2127fe20c577 (patch) | |
tree | 818bc86c7e90c438e09550a5174b3283d5e7b9e4 | |
parent | 7ee3ab7baa2165990d3fd358878d818154f7ee86 (diff) |
caddytls: Support placeholders in key_type (#3176)
* tls: Support placeholders in key_type
* caddytls: Simplify placeholder support for ap.KeyType
Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
-rw-r--r-- | modules/caddytls/automation.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/caddytls/automation.go b/modules/caddytls/automation.go index 73c12f9..fcf6454 100644 --- a/modules/caddytls/automation.go +++ b/modules/caddytls/automation.go @@ -183,8 +183,19 @@ func (ap *AutomationPolicy) Provision(tlsApp *TLS) error { ap.Issuer = val.(certmagic.Issuer) } + keyType := ap.KeyType + if keyType != "" { + var err error + keyType, err = caddy.NewReplacer().ReplaceOrErr(ap.KeyType, true, true) + if err != nil { + return fmt.Errorf("invalid key type %s: %s", ap.KeyType, err) + } + if _, ok := supportedCertKeyTypes[keyType]; !ok { + return fmt.Errorf("unrecognized key type: %s", keyType) + } + } keySource := certmagic.StandardKeyGenerator{ - KeyType: supportedCertKeyTypes[ap.KeyType], + KeyType: supportedCertKeyTypes[keyType], } storage := ap.storage |