anterofit
anterofit copied to clipboard
https does not work out of the box.
Tried setting it up today to interface to an api I use at work, and it does not work. Seems to not know what an https:// URL is...
Do you have any examples that work with https with the latest dependencies?
Thanks!
That's more of a Hyper limitation actually. Fortunately it's pretty simple to fix up, you just have to construct a hyper::Client
with a TLS-capable Connector. hyper-native-tls
seems to be the best implementation of that right now:
Cargo.toml:
[dependencies]
# ADD
hyper-native-tls = "0.3"
Then when building your Adaptor:
extern crate hyper_native_tls;
extern crate anterofit;
use hyper_native_tls::NativeTlsClient;
use anterofit::Adapter;
use anterofit::hyper::net::HttpsConnector;
use anterofit::hyper::Client;
let ssl = NativeTlsClient::new().unwrap(); // or handle the error
let connector = HttpsConnector::new(ssl);
let client = Client::with_connector(connector);
let adapter = Adapter::builder().client(client).build();
Perfect! Thank you!
Could you add this to the docs somewhere please? So others don't get discouraged if it does not work at first.