Skip to content

Commit 4f22430

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 fc352e7 commit 4f22430

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
@@ -270,6 +270,7 @@ type ACL struct{}
270270
//test:ok:bind :443 ssl tls-tickets
271271
//test:ok:bind :443 ssl no-strict-sni
272272
//test:ok:bind :443 ssl crt mycert1.pem crt mycert2.pem crt mycert3.pem
273+
//test:ok:bind :443 ssl crt-list list1.txt crt-list list2.txt
273274
//test:fail:bind :443 idle-ping
274275
//test:fail:bind :443 user
275276
//test:fail:bind :443 user mode 600

configuration/bind.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,11 @@ func parseBindParams(bindOptions []params.BindOption) (models.BindParams, string
352352
case "crt-ignore-err":
353353
b.CrtIgnoreErr = v.Value
354354
case "crt-list":
355-
b.CrtList = v.Value
355+
if b.CrtList == "" {
356+
b.CrtList = v.Value
357+
} else {
358+
b.CrtList = fmt.Sprintf("%s:%s", b.CrtList, v.Value)
359+
}
356360
case "default-crt":
357361
if b.DefaultCrtList == nil {
358362
b.DefaultCrtList = []string{}
@@ -555,7 +559,9 @@ func serializeBindParams(b models.BindParams, name string, path string, opt *opt
555559
options = append(options, &params.BindOptionValue{Name: "crt-ignore-err", Value: b.CrtIgnoreErr})
556560
}
557561
if b.CrtList != "" {
558-
options = append(options, &params.BindOptionValue{Name: "crt-list", Value: b.CrtList})
562+
for crtList := range strings.SplitSeq(b.CrtList, ":") {
563+
options = append(options, &params.BindOptionValue{Name: "crt-list", Value: crtList})
564+
}
559565
}
560566
if b.DefaultCrtList != nil {
561567
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
@@ -294,6 +294,7 @@ definitions:
294294
ssl:
295295
value: true
296296
crt_list:
297+
description: All of the certificate list files delimited by ':' as mentioned as a crt-list on the bind line.
297298
type: string
298299
x-dependency:
299300
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)