0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-30 22:34:15 -05:00

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>
This commit is contained in:
Pascal 2020-03-26 06:16:12 +01:00 committed by GitHub
parent 7ee3ab7baa
commit 5c55e5d53f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,8 +183,19 @@ func (ap *AutomationPolicy) Provision(tlsApp *TLS) error {
ap.Issuer = val.(certmagic.Issuer) 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{ keySource := certmagic.StandardKeyGenerator{
KeyType: supportedCertKeyTypes[ap.KeyType], KeyType: supportedCertKeyTypes[keyType],
} }
storage := ap.storage storage := ap.storage