sfackler / rust-native-tls

Apache License 2.0
468 stars 197 forks source link

TlsConnectorBuilder constructor #266

Closed lapointexavier closed 1 year ago

lapointexavier commented 1 year ago

Hi,

I wanted to use the TLsConnectorBuilder to add a self signed certificate, and it appears that there's no default constructor for that struct. I know this is very minor, but I was wondering if either I didn't look properly, or if there was an opportunity to improve this api.

Currently I think I'd need to fill in all fields:

TlsConnectorBuilder {
  identity: None,
  min_protocol: None,
  ...
}.add_root_certificates(...).build()

And I'd like to write something similar to:

TlsConnectorBuilder::new().add_root_certificates(...).build()

I assume the default (either through TlsConnectorBuilder::new() or impl Default for TlsConnectorBuilder) would need to populate sensible values.

I'd be happy to contribute.

Thank you

lapointexavier commented 1 year ago

My apologies, just saw a test where TlsConnector::builder() is used.

rust1248 commented 1 year ago

I stumbled upon this today, I think it should be documented on TlsConnectorBuilder (how to get one)