Skip to content

Commit 4635ad0

Browse files
committed
crypto/tls: align cert decode alert w/ BSSL
For malformed client/server certificates in a TLS handshake send a decode_error alert, matching BoringSSL behaviour. Previously crypto/tls used a bad_certificate alert for this purpose. The TLS specification is imprecise enough to allow this to be considered a spec. justified choice, but since all other places in the protocol encourage using decode_error for structurally malformed messages we may as well do the same here and get some extra cross-impl consistency for free. This also allows un-ignoring the BoGo GarbageCertificate-[Client|Server]-[TLS12|TLS13] tests. Updates #72006 Change-Id: Ide45ba1602816e71c3289a60e77587266c3b9036 Reviewed-on: https://go-review.googlesource.com/c/go/+/652995 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
1 parent 5b4209f commit 4635ad0

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

src/crypto/tls/bogo_config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"KyberKeyShareIncludedSecond": "we always send the Kyber key share first",
5555
"KyberKeyShareIncludedThird": "we always send the Kyber key share first",
5656
"GREASE-Server-TLS13": "We don't send GREASE extensions",
57-
"GarbageCertificate*": "TODO ask davidben, alertDecode vs alertBadCertificate",
5857
"SendBogusAlertType": "sending wrong alert type",
5958
"EchoTLS13CompatibilitySessionID": "TODO reject compat session ID",
6059
"*Client-P-224*": "no P-224 support",

src/crypto/tls/handshake_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ func (c *Conn) verifyServerCertificate(certificates [][]byte) error {
10961096
for i, asn1Data := range certificates {
10971097
cert, err := globalCertCache.newCert(asn1Data)
10981098
if err != nil {
1099-
c.sendAlert(alertBadCertificate)
1099+
c.sendAlert(alertDecodeError)
11001100
return errors.New("tls: failed to parse certificate from server: " + err.Error())
11011101
}
11021102
if cert.cert.PublicKeyAlgorithm == x509.RSA {

src/crypto/tls/handshake_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ func (c *Conn) processCertsFromClient(certificate Certificate) error {
909909
var err error
910910
for i, asn1Data := range certificates {
911911
if certs[i], err = x509.ParseCertificate(asn1Data); err != nil {
912-
c.sendAlert(alertBadCertificate)
912+
c.sendAlert(alertDecodeError)
913913
return errors.New("tls: failed to parse client certificate: " + err.Error())
914914
}
915915
if certs[i].PublicKeyAlgorithm == x509.RSA {

0 commit comments

Comments
 (0)