Skip to content

Commit 8dea78e

Browse files
author
Julien Pivotto
authored
Merge pull request #58 from LeviHarrison/fix-typo
Fix ClientAuth type typo
2 parents e283c80 + 235ade0 commit 8dea78e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tls_server_config:
2+
cert_file: "server.crt"
3+
key_file: "server.key"
4+
client_auth_type: "RequireAnyClientCert"
5+
client_ca_file: "tls-ca-chain.pem"

web/tls_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func ConfigToTLSConfig(c *TLSStruct) (*tls.Config, error) {
154154
switch c.ClientAuth {
155155
case "RequestClientCert":
156156
cfg.ClientAuth = tls.RequestClientCert
157-
case "RequireClientCert":
157+
case "RequireAnyClientCert", "RequireClientCert": // Preserved for backwards compatibility.
158158
cfg.ClientAuth = tls.RequireAnyClientCert
159159
case "VerifyClientCertIfGiven":
160160
cfg.ClientAuth = tls.VerifyClientCertIfGiven

web/tls_config_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ var (
5353
"Unknown TLS version": regexp.MustCompile(`unknown TLS version`),
5454
"No HTTP2 cipher": regexp.MustCompile(`TLSConfig.CipherSuites is missing an HTTP/2-required`),
5555
"Incompatible TLS version": regexp.MustCompile(`protocol version not supported`),
56+
"Bad certificate": regexp.MustCompile(`bad certificate`),
5657
}
5758
)
5859

@@ -280,6 +281,12 @@ func TestServerBehaviour(t *testing.T) {
280281
UseTLSClient: true,
281282
ExpectedError: ErrorMap["No HTTP2 cipher"],
282283
},
284+
{
285+
Name: `valid tls config yml and tls client with RequireAnyClientCert`,
286+
YAMLConfigPath: "testdata/tls_config_noAuth.requireanyclientcert.good.yml",
287+
UseTLSClient: true,
288+
ExpectedError: ErrorMap["Bad certificate"],
289+
},
283290
}
284291
for _, testInputs := range testTables {
285292
t.Run(testInputs.Name, testInputs.Test)

0 commit comments

Comments
 (0)