tokio-rs/tokio-tls

Wrong SslContext

tekjar opened this issue · 1 comments

Hi. How do I set certificates?

https://tokio-rs.github.io/tokio-tls/tokio_tls/struct.ClientContext.html

This is pointing to openssl SslContext but I'm facing errors with below code

let cx = ClientContext::new().unwrap();
        {
            let backend_cx = cx.ssl_context_mut();
            let _ = backend_cx.set_CA_file("ca.crt");
            let _ = backend_cx.set_certificate_file("test.crt", X509FileType::PEM);
            let _ = backend_cx.set_private_key_file("test.key", X509FileType::PEM);
        }
        cx.handshake("server:8883", socket)

Error

error: no method named `set_CA_file` found for type `&mut security_framework::secure_transport::SslContext` in the current scope
src/main.rs:26             let _ = backend_cx.set_CA_file("/home/raviteja/Desktop/mqtt_gcloud_certs/ca.crt");
                                              ^~~~~~~~~~~
src/main.rs:27:32: 27:52 error: no method named `set_certificate_file` found for type `&mut security_framework::secure_transport::SslContext` in the current scope
src/main.rs:27             let _ = backend_cx.set_certificate_file("/home/raviteja/Desktop/mqtt_gcloud_certs/client_mqtt_veh_test.crt", X509FileType::PEM);
                                              ^~~~~~~~~~~~~~~~~~~~
src/main.rs:28:32: 28:52 error: no method named `set_private_key_file` found for type `&mut security_framework::secure_transport::SslContext` in the current scope
src/main.rs:28             let _ = backend_cx.set_private_key_file("/home/raviteja/Desktop/mqtt_gcloud_certs/client_mqtt_veh_test.key", X509FileType::PEM);

This is a general problem w/ generating rustdocs. I would recommend you run cargo doc on your dev box. This will generate docs for OS X in target/doc/tokio-tls and you can see what is available there.

Once the crate is pushed to crates.io, https://docs.rs will generate docs for all supported platforms.

Hope this helps.