anterofit icon indicating copy to clipboard operation
anterofit copied to clipboard

https does not work out of the box.

Open bentwire opened this issue 6 years ago • 3 comments

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!

bentwire avatar Dec 27 '18 04:12 bentwire

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();

abonander avatar Dec 27 '18 04:12 abonander

Perfect! Thank you!

bentwire avatar Dec 27 '18 04:12 bentwire

Could you add this to the docs somewhere please? So others don't get discouraged if it does not work at first.

bentwire avatar Dec 27 '18 08:12 bentwire