Skip to content

Commit a7e3a2f

Browse files
committed
BUG/MAJOR: bind: allow bind to parse multiple crt-list options
They are now parsed and serialized as CrtList field on the bind object and delimited by ':'.
1 parent 0564d06 commit a7e3a2f

13 files changed

Lines changed: 61 additions & 4 deletions

File tree

config-parser/tests/bind_generated_test.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config-parser/tests/configs/haproxy_generated.cfg.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config-parser/tests/integration/frontend_data_test.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config-parser/tests/integration/frontend_test.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config-parser/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ type ACL struct{}
260260
//test:ok:bind :443 ssl tls-tickets
261261
//test:ok:bind :443 ssl no-strict-sni
262262
//test:ok:bind :443 ssl crt mycert1.pem crt mycert2.pem crt mycert3.pem
263+
//test:ok:bind :443 ssl crt-list list1.txt crt-list list2.txt
263264
//test:fail:bind :443 idle-ping
264265
//test:fail:bind :443 user
265266
//test:fail:bind :443 user mode 600

configuration/bind.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,11 @@ func parseBindParams(bindOptions []params.BindOption) (models.BindParams, string
357357
case "crt-ignore-err":
358358
b.CrtIgnoreErr = v.Value
359359
case "crt-list":
360-
b.CrtList = v.Value
360+
if b.CrtList == "" {
361+
b.CrtList = v.Value
362+
} else {
363+
b.CrtList = fmt.Sprintf("%s:%s", b.CrtList, v.Value)
364+
}
361365
case "default-crt":
362366
if b.DefaultCrtList == nil {
363367
b.DefaultCrtList = []string{}
@@ -563,7 +567,9 @@ func serializeBindParams(b models.BindParams, name string, path string, opt *opt
563567
options = append(options, &params.BindOptionValue{Name: "crt-ignore-err", Value: b.CrtIgnoreErr})
564568
}
565569
if b.CrtList != "" {
566-
options = append(options, &params.BindOptionValue{Name: "crt-list", Value: b.CrtList})
570+
for crtList := range strings.SplitSeq(b.CrtList, ":") {
571+
options = append(options, &params.BindOptionValue{Name: "crt-list", Value: crtList})
572+
}
567573
}
568574
if b.DefaultCrtList != nil {
569575
for _, dc := range b.DefaultCrtList {

configuration/bind_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package configuration
2+
3+
import (
4+
"testing"
5+
6+
"github.com/haproxytech/client-native/v6/config-parser/params"
7+
"github.com/haproxytech/client-native/v6/configuration/options"
8+
"github.com/haproxytech/client-native/v6/models"
9+
10+
"github.com/stretchr/testify/require"
11+
)
12+
13+
func TestParseBindParamsMultipleCrtList(t *testing.T) {
14+
bindOptions := []params.BindOption{
15+
&params.BindOptionValue{Name: "crt-list", Value: "list1.txt"},
16+
&params.BindOptionValue{Name: "crt-list", Value: "list2.txt"},
17+
}
18+
19+
b, _ := parseBindParams(bindOptions)
20+
21+
require.Equal(t, "list1.txt:list2.txt", b.CrtList)
22+
}
23+
24+
func TestSerializeBindParamsMultipleCrtList(t *testing.T) {
25+
b := models.BindParams{CrtList: "list1.txt:list2.txt"}
26+
27+
bindOptions := serializeBindParams(b, "", "", &options.ConfigurationOptions{})
28+
29+
var crtLists []string
30+
for _, o := range bindOptions {
31+
if v, ok := o.(*params.BindOptionValue); ok && v.Name == "crt-list" {
32+
crtLists = append(crtLists, v.Value)
33+
}
34+
}
35+
require.Equal(t, []string{"list1.txt", "list2.txt"}, crtLists)
36+
}

models/bind_params.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/build/haproxy_spec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ definitions:
254254
ssl:
255255
value: true
256256
crt_list:
257+
description: All of the certificate list files delimited by ':' as mentioned as a crt-list on the bind line.
257258
type: string
258259
x-dependency:
259260
ssl:

specification/models/configuration/bind_params.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ bind_params:
8080
value: true
8181
crt_list:
8282
type: string
83+
description: All of the certificate list files delimited by ':' as mentioned as a crt-list on the bind line.
8384
x-dependency:
8485
ssl:
8586
value: true

0 commit comments

Comments
 (0)