From b814c0af9c2c20a92f86e4db9836fd6b127dcf5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20B=C4=99dkowski?= Date: Wed, 6 May 2020 16:07:13 +0000 Subject: tls/client auth: verify first certificates in client request (#3344) When client certificate is enabled Caddy check only last certificate from request. When this cert is not in list of trusted leaf certificates, connection is rejected. According to RFC TLS1.x the sender's certificate must come first in the list. Each following certificate must directly certify the one preceding it. This patch fix this problem - first certificate is checked instead of last. --- modules/caddytls/connpolicy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/caddytls') diff --git a/modules/caddytls/connpolicy.go b/modules/caddytls/connpolicy.go index 1de7c2e..3a18061 100644 --- a/modules/caddytls/connpolicy.go +++ b/modules/caddytls/connpolicy.go @@ -395,7 +395,7 @@ func (clientauth ClientAuthentication) verifyPeerCertificate(rawCerts [][]byte, return fmt.Errorf("no client certificate provided") } - remoteLeafCert, err := x509.ParseCertificate(rawCerts[len(rawCerts)-1]) + remoteLeafCert, err := x509.ParseCertificate(rawCerts[0]) if err != nil { return fmt.Errorf("can't parse the given certificate: %s", err.Error()) } -- cgit v1.2.3