Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
caddytls: add 'key_type' subdirective (#3956)
* caddytls: add 'key_type' subdirective * Suggested change * *string -> string * test
Jordi Masip committed
Jan 6, 2021 at 20:02 UTC
8b6fdc04da5b31d8cb62b9d2574d16afe81ad549
3 files changed
+21
caddyconfig/httpcaddyfile/builtins.go
+15
@@ -87,6 +87,7 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
87
var folderLoader caddytls.FolderLoader
88
var certSelector caddytls.CustomCertSelectionPolicy
89
var acmeIssuer *caddytls.ACMEIssuer
90
+ var keyType string
91
var internalIssuer *caddytls.InternalIssuer
92
var issuers []certmagic.Issuer
93
var onDemand bool
@@ -267,6 +268,13 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
268
}
269
acmeIssuer.CA = arg[0]
270
271
+ case "key_type":
272
+ arg := h.RemainingArgs()
273
+ if len(arg) != 1 {
274
+ return nil, h.ArgErr()
275
+ }
276
+ keyType = arg[0]
277
+
278
case "eab":
279
arg := h.RemainingArgs()
280
if len(arg) != 2 {
@@ -384,6 +392,13 @@ func parseTLS(h Helper) ([]ConfigValue, error) {
392
})
393
}
394
395
+ if keyType != "" {
396
+ configVals = append(configVals, ConfigValue{
397
+ Class: "tls.key_type",
398
+ Value: keyType,
399
+ })
400
+ }
401
+
402
// on-demand TLS
403
if onDemand {
404
configVals = append(configVals, ConfigValue{
caddyconfig/httpcaddyfile/tlsapp.go
+4
@@ -108,6 +108,10 @@ func (st ServerType) buildTLSApp(
108
ap.OnDemand = true
109
}
110
111
+ if keyTypeVals, ok := sblock.pile["tls.key_type"]; ok {
112
+ ap.KeyType = keyTypeVals[0].Value.(string)
113
+ }
114
+
115
// certificate issuers
116
if issuerVals, ok := sblock.pile["tls.cert_issuer"]; ok {
117
var issuers []certmagic.Issuer
caddytest/integration/caddyfile_adapt/tls_automation_policies_2.txt
+2
@@ -7,6 +7,7 @@
7
example.com {
8
tls {
9
on_demand
10
+ key_type rsa2048
11
}
12
}
13
@@ -79,6 +80,7 @@ http://example.net {
80
"module": "zerossl"
81
}
82
],
83
+ "key_type": "rsa2048",
84
"on_demand": true
85
},
86
{