From 5c55e5d53fcd5f60921dc477a4eb2127fe20c577 Mon Sep 17 00:00:00 2001 From: Pascal Date: Thu, 26 Mar 2020 06:16:12 +0100 Subject: 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 --- modules/caddytls/automation.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3