-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement certificate compression #95
Implement certificate compression #95
Conversation
|
||
require ( | ||
github.com/andybalholm/brotli v1.0.4 | ||
github.com/klauspost/compress v1.13.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two dependencies are necessary to support Brotli and Zstandard decompression. I added a go.mod file to allow users of this package to more readily import.
FAKE_TLS_DHE_RSA_WITH_AES_256_CBC_SHA = uint16(0x0039) | ||
FAKE_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = uint16(0x009f) | ||
FAKE_TLS_RSA_WITH_RC4_128_MD5 = uint16(0x0004) | ||
FAKE_TLS_EMPTY_RENEGOTIATION_INFO_SCSV = uint16(0x00ff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gofmt
did this
Because there is no server-side implementation, it would be complex to write a proper test for this new logic. I did add the new message to existing tests for message marshaling / unmarshaling. I also tested this against a number of live sites, including a number which support certificate compression and a number which do not. I manually verified that we were parsing and handling the compressed certificate as expected. If desired, I could add a semi-manual test, like:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested your code and I think you forgot to add a line of code.
Without a change, hs.uconn.certCompressionAlgs
is never set and always nil
resulting in the following error: tls: received unexpected handshake message of type *tls.compressedCertificateMsg when waiting for *tls.certificateMsgTLS13
.
See the review.
} | ||
|
||
func (e *UtlsCompressCertExtension) writeToUConn(uc *UConn) error { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil | |
uc.certCompressionAlgs = e.Methods | |
return nil |
f77a4e9
to
90154a8
Compare
Certificate compression is defined in RFC 8879: https://datatracker.ietf.org/doc/html/rfc8879 This implementation is client-side only, for server certificates.
90154a8
to
048f18c
Compare
You're totally right @sleeyax! I ported this from our fork (which is ahead) and messed up that part of the port. Thanks for the catch! I went through and double-checked everything else and it seems correct. Apologies for the delayed response! |
I have noticed that the fork does not always manage to decompress retrieved certificates. For example, for Another feature that I'd like to see with this fork is to have a flag (maybe in TLS 1.3 state?) that denotes if the server really replied with a compressed certificate chain. |
Thanks for pointing that out @yan-foto, I was not aware. I'll try to figure out what's going on there.
Could you expand on the use case for this feature? Unfortunately it will probably be a few weeks before I have time to really dig into this stuff. But I will get to it! |
@hwh33 Thanks for the quick reply!
We scan TLS-enabled hosts and want to verify if and which compression algorithms they support. At the moment there is no way to see if certificate chain was really compressed or if the server ignored our request and just returned the certificates uncompressed.
Thanks. I'm not in a hurry. I forked your version and hacked my way into it. But it's not something that anyone would want to have in production! |
Approved, tested and merged. Thanks for contributing! 🎉 |
Nice catch! Definitely something we would like to fix.
Interesting observation. Will need more details on that. |
Thanks @hwh33! I will get it merged. |
Certificate compression is defined in RFC 8879:
https://datatracker.ietf.org/doc/html/rfc8879
This implementation is client-side only, for server certificates.
Some parrots (e.g.
HelloChrome_83
) advertise certificate compression. This PR allows clients to connect to hosts which implement certificate compression.