-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Avoid relying on internals of crypto/tls #2727
Comments
Hello @FiloSottile, Thank you for opening this issue. I'd really really love to do that, the dependency on crypto/tls has been a huge pain point in the past, and I've spent a fair amount of time thinking about solutions for this problem. Conceptually, forking crypto/tls indeed seems like the cleanest solution. This kind of API makes it trivial to use the same I've tried to mitigate the security impact of the unsafe operations as far as possible by building a function that compares the structs: Adding an (exported or unexported) field to a struct will cause that check to fail, as will a reordering and a renaming. This code is run on I'd be very happy about suggestions how to solve this problem. |
Do you need access to any of the unexported fields? Because otherwise something that might work is to make a simple |
Another problem is the The |
Yeah more or less. We pre generate the configs at startup and then use our own config selection logic so the user can customize which config is chosen at each handshake. Our configs also handle GetCertificate callback so we can present an ACME cert during challenges and even perform cert maintenance during handshakes if necessary. |
I also maintain a custom implementation based on crypto/tls for another QUIC implementation. I'm trying to reuse tls.Config as much as I can but still haven't found a proper way to get/reuse the session tickets in tls.Config. It'd be much easier if tls.Config didn't contain unexported fields, but had a |
I've noticed on #2614 that you're relying on unsafe casting to crypto/tls internal structures. I'm writing this to ask to please not do that.
Of course, that's not covered by any compatibility promise, but you know that. What you might not be considering is that we might and eventually will change internals for a security release, and then your users will be forced to choose between a security vulnerability and dropping a dependency in a hurry. Even more worrying, is that we might replace a field with a different one of the same type, and you might end up violating security-critical invariants without noticing.
Instead, please fork crypto/tls, and apply our changes on your own schedule, integrating them with the rest of the module. I hear
git subtree
is nice for that. You can even try to expose everything you need as clear, separate APIs, so you can more easily audit the contact points, and maybe eventually even get them upstreamed. It might require some more work upfront, but the only way to safely do what you are doing is anyway to be aware of every single change in crypto/tls.The text was updated successfully, but these errors were encountered: