This commit is contained in:
Adrian Heine 2017-06-24 11:04:59 +02:00
parent f43ba0da97
commit e8b8122973
7 changed files with 104 additions and 6 deletions

View file

@ -42,8 +42,18 @@ impl<'a> Symbol for SelfSignedTlsCert<'a> {
if !Path::new(&self.get_cert_path()).exists() {
return Ok(false);
}
let output = try!(self.command_runner.get_output("openssl", &["x509", "-in", &self.get_cert_path(), "-noout", "-subject", "-checkend", &(30*DAYS_IN_SECONDS).to_string()]));
Ok(output == format!("subject=CN = {}\nCertificate will not expire\n", self.domain).as_bytes())
let output = try!(self.command_runner.run_with_args("openssl", &["x509", "-in", &self.get_cert_path(), "-noout", "-subject", "-checkend", &(30*DAYS_IN_SECONDS).to_string()]));
println!("{}", output.status.code().unwrap());
match output.status.code() {
Some(0) => Ok(output.stdout == format!("subject=CN = {}\nCertificate will not expire\n", self.domain).as_bytes()),
Some(_) => if output.stdout == format!("subject=CN = {}\nCertificate will expire\n", self.domain).as_bytes() {
Ok(false)
} else {
Err("Exit code non-zero, but wrong stdout".to_string().into())
},
_ => Err("Apparently killed by signal".to_string().into())
}
}
fn execute(&self) -> Result<(), Box<Error>> {