-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tls_first_implementation #155
Conversation
5708e75
to
b852fbd
Compare
b852fbd
to
61d2803
Compare
src/client/mod.rs
Outdated
let conn = tls_builder.build(); | ||
|
||
let conn = tokio_native_tls::TlsConnector::from(conn.unwrap()); | ||
|
||
let stream = conn.connect(broker.host.as_str(), stream).await; | ||
|
||
GenericTcpStream::SecureTcp(stream.unwrap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use ?
here instead of unwrap()
let conn = tls_builder.build(); | |
let conn = tokio_native_tls::TlsConnector::from(conn.unwrap()); | |
let stream = conn.connect(broker.host.as_str(), stream).await; | |
GenericTcpStream::SecureTcp(stream.unwrap()) | |
let conn = tokio_native_tls::TlsConnector::from(tls_builder.build()?); | |
let stream = conn.connect(broker.host.as_str(), stream).await?; | |
GenericTcpStream::SecureTcp(stream) |
pub struct TlsConfiguration { | ||
pub(crate) enabled: bool, | ||
pub(crate) hostname_verification: bool, | ||
pub(crate) trust_everything: bool, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the TlsConfiguration
probably it's better if we do a builder pattern?
Something like this
pub struct TlsConfigurationBuilder(TlsConfiguration);
impl TlsConfigurationBuilder {
pub fn trust_everything(mut self, trust_everything: bool) -> TlsConfigurationBuilder {
self.0.trust_everything = trust_everything;
self
}
pub fn enable(mut self, enable: bool) -> TlsConfigurationBuilder {
self.0.enabled = enabled;
self
}
pub fn hostname_verification_enable(mut self, hostname_verification: bool) -> TlsConfigurationBuilder {
self.0.hostname_verification = hostname_verification;
self
}
pub fn build(self) -> TlsConfiguration {
self.0
}
}
impl TlsConfiguration {
pub fn builder() -> TlsConfigurationBulder {
TlsConfigurationBulder(TlsConfiguration::default())
}
}
fba7600
to
139ac44
Compare
139ac44
to
4c2661d
Compare
Hey @wolf4ood thanks for your review! Addressed the issues! |
This first implementation of TLS support includes: