websockets-rs / rust-websocket

A WebSocket (RFC6455) library written in Rust
http://websockets-rs.github.io/rust-websocket/
MIT License
1.55k stars 223 forks source link

Expose native_tls as it's needed to use your API #247

Closed levelonedev closed 4 years ago

levelonedev commented 5 years ago

In order to use any of the connect functions I would be required to depend on native_tls directly. It would be easier if you exposed the version you depend on.

use native_tls::TlsConnector; //Errors out currently
use websocket::native_tls::{TlsConnector, Certificate}; //What I propose

let mut file = File::open("cert.pem")?;
let mut data:Vec<u8> = Vec::new();
file.read_to_end(&mut data);
let root_ca = Certificate::from_pem(&data)?;
let connector = TlsConnector::builder().add_root_certificate(root_ca).build()?;

let mut builder: ClientBuilder = ClientBuilder::from_url(&self.url);
let mut client = builder.connect(Some(connector))?;