-
-
Notifications
You must be signed in to change notification settings - Fork 203
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 hostname checking against a custom CN #141
base: master
Are you sure you want to change the base?
Conversation
Why wouldn't you just pass the custom cn in the |
Ah, shoot. The And indeed, the CN is ought to be So, either there is room for implementing callback-based, more customizable validation, or exposing the functionality in the higher level libraries. Hmm... |
I mean, code like this doesn't seem to leave leeway for customization. I wonder which part of the stack would be a "correct" place to do this.
|
It seems that the correct place to inject the CN would be on the occasion of calling |
@sfackler Do you think there could be common ground between the three TLS backends to implement and provide some kind callback-based custom verification API? I know that OpenSSL provides means for this, but I know nothing about the other two, and the difference between the APIs between the three could provide hard to abstract over. FWIW, I asked in Reqwest repo about support for setting the hostname on TLS connect. I guess with Hyper you would be able to do it if you implement the |
It does seem like you'd want to be able to somewhere have a mapping from domain name to expected CN. I kind of think the right place for that would be up in hyper_tls, but I'm not 100% positive that's right. |
It also seems absurd that there isn't some more "normal" way of dealing with the AWS change than getting every TLS client to support custom CN overrides. |
Yes, it's kinda absurd. As far as I know, the current state of affairs is this: Since I don't know when and how they will eventually be supported, and I need to write code for even new buckets with dots (naming policies etc.), I'm investigating this. Thanks for sharing your thoughts! |
Overview
Implements an option
expect_custom_cn
forTlsConnectionBuilder
.For some use cases outside of the common HTTPS usage, the server hostname checking benefits from customizability.
My main use case is due to AWS's recent announcement[1] about phasing out "path style" URLs for the S3 storage service, favoring the "virtual host" style URLs. (For example from
https://s3.amazonaws.com/bucket.name/object.name
tohttps://bucket.name.s3.amazonaws.com/object.name
) The problem with this is that S3 bucket names can contain dots, but they are certified using a wildcard certificate with CN*.s3.amazonaws.com
. Because wildcards don't match multiple labels, S3 buckets with dots in their names cause TLS errors.The immediate remedy would be to use
danger_accept_invalid_hostnames
, but this exposes the client to MitM attacks so it's unacceptable. The subdomain namespace is guaranteed to be used for bucket names by AWS who controls the DNSs3.amazonaws.com
and the bucket names, so implementing a custom check would be an acceptable solution here.I think that NativeTLS would benefit from this additional customizability.
TODO / Points of discussion
danger_
prefix like with the other method that disable/modify standard verification?impl Trait
in argument position, which requires Rust 1.26. If this crate is intended to compile with older compilers than that, I'm happy to change it.[1] https://aws.amazon.com/jp/blogs/aws/amazon-s3-path-deprecation-plan-the-rest-of-the-story/