Skip to content

Commit dfb55b0

Browse files
committed
add next_protos support to tlsconfig
Signed-off-by: david kydd <[email protected]>
1 parent 653e0fa commit dfb55b0

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

config/http_config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,10 @@ func NewTLSConfigWithContext(ctx context.Context, cfg *TLSConfig, optFuncs ...TL
10691069
tlsConfig.ServerName = cfg.ServerName
10701070
}
10711071

1072+
if len(cfg.NextProtos) > 0 {
1073+
tlsConfig.NextProtos = cfg.NextProtos
1074+
}
1075+
10721076
// If a client cert & key is provided then configure TLS config accordingly.
10731077
if cfg.usingClientCert() && cfg.usingClientKey() {
10741078
// Verify that client cert and key are valid.
@@ -1118,6 +1122,8 @@ type TLSConfig struct {
11181122
MinVersion TLSVersion `yaml:"min_version,omitempty" json:"min_version,omitempty"`
11191123
// Maximum TLS version.
11201124
MaxVersion TLSVersion `yaml:"max_version,omitempty" json:"max_version,omitempty"`
1125+
// Additional ALPN protocols to be presented when connecting to the server.
1126+
NextProtos []string `yaml:"next_protos,omitempty" json:"next_protos,omitempty"`
11211127
}
11221128

11231129
// SetDirectory joins any relative file paths with dir.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"next_protos": ["testproto1", "testproto2"]}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
next_protos: ["testproto1", "testproto2"]

config/tls_config_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ var expectedTLSConfigs = []struct {
6363
filename: "tls_config.insecure.good.json",
6464
config: &tls.Config{InsecureSkipVerify: true},
6565
},
66+
{
67+
filename: "tls_config.next_protos.good.json",
68+
config: &tls.Config{NextProtos: []string{"testproto1", "testproto2"}},
69+
},
6670
{
6771
filename: "tls_config.tlsversion.good.json",
6872
config: &tls.Config{MinVersion: tls.VersionTLS11},
@@ -79,6 +83,10 @@ var expectedTLSConfigs = []struct {
7983
filename: "tls_config.insecure.good.yml",
8084
config: &tls.Config{InsecureSkipVerify: true},
8185
},
86+
{
87+
filename: "tls_config.next_protos.good.yml",
88+
config: &tls.Config{NextProtos: []string{"testproto1", "testproto2"}},
89+
},
8290
{
8391
filename: "tls_config.tlsversion.good.yml",
8492
config: &tls.Config{MinVersion: tls.VersionTLS11},

0 commit comments

Comments
 (0)