hyperium / hyper-tls

Apache License 2.0
189 stars 96 forks source link

Control over TLS constructors #33

Closed frenchtoastbeer closed 5 years ago

frenchtoastbeer commented 5 years ago

So I get that this library is intended to be generic as pertains to TLS, but the way this is implemented I can't control anything in a TLS builder pattern.

With the native-tls rust crate, for example, I see that I need to set some boolean's in the builder struct in order to disable certificate and hostname validation. The native-tls TlsConnectorBuilder's methods include public setters for those booleans, but that's only usable during the builder pattern. I don't know how I would disable TLS validation after the connector is built, and I'd imagine it's different depending on what library is managing TLS in that particular instance. I get that none of that is hyper-tls's problem, and I agree.

But, and I'm a total rust newbie so maybe I'm just wrong here, shouldn't this library (which treats TLS generically) allow the caller to create the TLS object, and then pass that to HttpsConnector::new() ?

Are you already doing that somehow and I just missed it? If not, and you think that's probably how things should be done™ then I wouldn't mind submitting a pull request with the suggested changes.

seanmonstar commented 5 years ago

There is a HttpsConnector::from constructor that takes some underlying connector (like HttpConnector) and a TlsConnector. You can use the TlsConnectorBuilder and then call HttpsConnector::from((http, tls)).

frenchtoastbeer commented 5 years ago

I should have taken some time to read prior issues, I see this isn't the first time someone has had exactly my problem - thanks for your patience!