Strict SSL verification (#9)

Fixes #8
This commit is contained in:
Aram Peres 2021-07-31 11:12:45 -04:00 committed by GitHub
parent f22867d2d2
commit 3002b4de53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 171 additions and 75 deletions

View file

@ -41,15 +41,23 @@ fn main() -> anyhow::Result<()> {
.arg(
Arg::with_name("debug")
.short("D")
.long("debug")
.takes_value(false)
.help("Enables debug mode (logs network commands to stderr)."),
)
.arg(
Arg::with_name("ssl")
.short("S")
.long("ssl")
.takes_value(false)
.help("Enables SSL on the connection with upsd."),
)
.arg(
Arg::with_name("insecure-ssl")
.long("insecure-ssl")
.takes_value(false)
.help("Disables SSL verification on the connection with upsd."),
)
.arg(
Arg::with_name("upsd-server")
.required(false)
@ -70,13 +78,15 @@ fn main() -> anyhow::Result<()> {
)?;
let debug = args.is_present("debug");
let ssl = args.is_present("ssl");
let insecure_ssl = args.is_present("insecure-ssl");
let ssl = insecure_ssl || args.is_present("ssl");
let host = server.try_into()?;
let config = nut_client::ConfigBuilder::new()
.with_host(host)
.with_debug(debug)
.with_ssl(ssl)
.with_insecure_ssl(insecure_ssl)
.build();
if args.is_present("list") {