Add SSL support (#7)

Fixes #1
This commit is contained in:
Aram Peres 2021-07-31 08:43:26 -04:00 committed by GitHub
parent d78fd8c141
commit d36999db6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 494 additions and 104 deletions

View file

@ -11,6 +11,7 @@ A [Network UPS Tools](https://github.com/networkupstools/nut) (NUT) client libra
- Login with username and password
- List UPS devices
- List variables for a UPS device
- Connect securely with SSL (optional feature)
## Getting Started
@ -60,7 +61,7 @@ fn main() -> nut_client::Result<()> {
.with_debug(false) // Turn this on for debugging network chatter
.build();
let mut conn = Connection::new(config)?;
let mut conn = Connection::new(&config)?;
// Print a list of all UPS devices
println!("Connected UPS devices:");
@ -78,3 +79,12 @@ fn main() -> nut_client::Result<()> {
Ok(())
}
```
## SSL
You can turn on SSL support by adding `.with_ssl(true)` in the `ConfigBuilder`.
This requires the `ssl` feature, which uses `rustls` under the hood.
Note that this crate turns off all certificate validation at the moment, effectively
giving a false sense of security. If you'd like to contribute to this, see issue #8.