inre / rust-mq

RustMQ is the MQTT client written on pure Rust.
MIT License
190 stars 28 forks source link

TLS via Cert #23

Closed sinitcin closed 3 years ago

sinitcin commented 7 years ago

Hello! Can i use cert x.509 for Tls v1.2? Please do write a mini tutorial. Thks

sinitcin commented 7 years ago

Do you speak russian?

gorup commented 6 years ago
use openssl::ssl::{SslContext as OpenslContext, SslMethod};
use netopt::{NetworkOptions, SslContext};
.
.
.
    let mut openssl_context = OpenslContext::new(SslMethod::Tlsv1_2).unwrap();
    openssl_context.set_verify(openssl::ssl::SSL_VERIFY_PEER, None);
    openssl_context.set_private_key_file(priv_path, X509FileType::PEM).unwrap();
    openssl_context.set_certificate_file(pub_path, X509FileType::PEM).unwrap();
    openssl_context.set_CA_file(ca_path).unwrap();

    let mut netopt = NetworkOptions::new();
    netopt.tls(SslContext::new(openssl_context));
.
.
.