inre/rust-mq

TLS via Cert

sinitcin opened this issue · 2 comments

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

Do you speak russian?

gorup commented
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));
.
.
.