Last active
July 25, 2023 14:19
-
-
Save Gsantomaggio/52474bda544504ee74599484652776df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let stream = TcpStream::connect((broker.host.as_str(), broker.port)).await?; | |
let mut tls_builder: tokio_native_tls::native_tls::TlsConnectorBuilder = tokio_native_tls::native_tls::TlsConnector::builder(); | |
let cert_bytes = include_bytes!("result/ca_certificate.pem"); | |
let cert = Certificate::from_pem(cert_bytes).unwrap(); | |
let s = tls_builder.add_root_certificate(cert) | |
.danger_accept_invalid_hostnames(false) | |
// .danger_accept_invalid_certs(true) | |
.min_protocol_version(Some(tokio_native_tls::native_tls::Protocol::Tlsv12)); | |
let conn = tokio_native_tls::TlsConnector::from(s.build()?).connect(broker.host.as_str(), stream).await?; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment