Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

server doesn't close the connection when certificate verification fails #16

Closed
marten-seemann opened this issue Feb 21, 2019 · 1 comment · Fixed by #17
Closed

server doesn't close the connection when certificate verification fails #16

marten-seemann opened this issue Feb 21, 2019 · 1 comment · Fixed by #17
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@marten-seemann
Copy link
Collaborator

The only condition for which it works properly is when the signature of the certificate is wrong (i.e. the client is using a certificate that was issued for a different key). All other error conditions, e.g. expired cert, invalid length cert chain, etc., don't generate an error. For the client, the connection will stay open and Read will block indefinitely.

@marten-seemann marten-seemann added the kind/bug A bug in existing code (including security flaws) label Feb 21, 2019
@marten-seemann
Copy link
Collaborator Author

Unfortunately, the Go standard library doesn't provide us any method to send a TLS alert (tls.Conn.sendAlert is not exported). So if we verify the certificate chain after establishing the connection, all we can do is call tls.Conn.Close(), which will be interpreted as a regular EOF by the client, not as an error.
The only way to actually send a TLS alert seems to be to return an error from the tls.Config.VerifyPeerCertificate callback. However, I really want to avoid parsing the client's certificate chain twice.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant