Skip to content

Commit f658fd0

Browse files
authored
reverseproxy: Add tls_curves option to HTTP transport (#5851)
1 parent cc0c0cf commit f658fd0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

modules/caddyhttp/reverseproxy/caddyfile.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,16 @@ func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
10721072
}
10731073
h.TLS.InsecureSkipVerify = true
10741074

1075+
case "tls_curves":
1076+
args := d.RemainingArgs()
1077+
if len(args) == 0 {
1078+
return d.ArgErr()
1079+
}
1080+
if h.TLS == nil {
1081+
h.TLS = new(TLSConfig)
1082+
}
1083+
h.TLS.Curves = args
1084+
10751085
case "tls_timeout":
10761086
if !d.NextArg() {
10771087
return d.ArgErr()

modules/caddyhttp/reverseproxy/httptransport.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ type TLSConfig struct {
491491
// When specified, TLS will automatically be configured on the transport.
492492
// The value can be a list of any valid tcp port numbers, default empty.
493493
ExceptPorts []string `json:"except_ports,omitempty"`
494+
495+
// The list of elliptic curves to support. Caddy's
496+
// defaults are modern and secure.
497+
Curves []string `json:"curves,omitempty"`
494498
}
495499

496500
// MakeTLSClientConfig returns a tls.Config usable by a client to a backend.
@@ -579,6 +583,15 @@ func (t TLSConfig) MakeTLSClientConfig(ctx caddy.Context) (*tls.Config, error) {
579583
// throw all security out the window
580584
cfg.InsecureSkipVerify = t.InsecureSkipVerify
581585

586+
curvesAdded := make(map[tls.CurveID]struct{})
587+
for _, curveName := range t.Curves {
588+
curveID := caddytls.SupportedCurves[curveName]
589+
if _, ok := curvesAdded[curveID]; !ok {
590+
curvesAdded[curveID] = struct{}{}
591+
cfg.CurvePreferences = append(cfg.CurvePreferences, curveID)
592+
}
593+
}
594+
582595
// only return a config if it's not empty
583596
if reflect.DeepEqual(cfg, new(tls.Config)) {
584597
return nil, nil

0 commit comments

Comments
 (0)