|
@ -20,10 +20,6 @@ impl<'a, C: CommandRunner> AcmeAccountKey<'a, C> { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn get_path(&self) -> &Path {
|
|
|
|
|
|
self.path.borrow()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn get_bytes(&self) -> u32 {
|
|
|
fn get_bytes(&self) -> u32 {
|
|
|
4096
|
|
|
4096
|
|
|
}
|
|
|
}
|
|
@ -31,25 +27,25 @@ impl<'a, C: CommandRunner> AcmeAccountKey<'a, C> { |
|
|
|
|
|
|
|
|
impl<'a, C: CommandRunner> fmt::Display for AcmeAccountKey<'a, C> {
|
|
|
impl<'a, C: CommandRunner> fmt::Display for AcmeAccountKey<'a, C> {
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
write!(f, "AcmeAccountKey {}", self.get_path().display())
|
|
|
|
|
|
|
|
|
write!(f, "AcmeAccountKey {}", self.path.display())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<'a, C: CommandRunner> Symbol for AcmeAccountKey<'a, C> {
|
|
|
impl<'a, C: CommandRunner> Symbol for AcmeAccountKey<'a, C> {
|
|
|
fn target_reached(&self) -> Result<bool, Box<Error>> {
|
|
|
fn target_reached(&self) -> Result<bool, Box<Error>> {
|
|
|
if !self.get_path().exists() {
|
|
|
|
|
|
|
|
|
if !self.path.exists() {
|
|
|
return Ok(false);
|
|
|
return Ok(false);
|
|
|
}
|
|
|
}
|
|
|
let stdout = try!(self.command_runner.get_output("openssl", &["rsa".as_ref(), "-in".as_ref(), self.get_path().as_os_str(), "-noout".as_ref(), "-check".as_ref(), "-text".as_ref()]));
|
|
|
|
|
|
|
|
|
let stdout = try!(self.command_runner.get_output("openssl", &["rsa".as_ref(), "-in".as_ref(), self.path.as_os_str(), "-noout".as_ref(), "-check".as_ref(), "-text".as_ref()]));
|
|
|
Ok(stdout.starts_with(&format!("Private-Key: ({} bit)\n", self.get_bytes()).as_bytes()))
|
|
|
Ok(stdout.starts_with(&format!("Private-Key: ({} bit)\n", self.get_bytes()).as_bytes()))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn execute(&self) -> Result<(), Box<Error>> {
|
|
|
fn execute(&self) -> Result<(), Box<Error>> {
|
|
|
self.command_runner.run_successfully("openssl", &["genrsa".as_ref(), "-out".as_ref(), self.get_path().as_os_str(), self.get_bytes().to_string().as_ref()])
|
|
|
|
|
|
|
|
|
self.command_runner.run_successfully("openssl", &["genrsa".as_ref(), "-out".as_ref(), self.path.as_os_str(), self.get_bytes().to_string().as_ref()])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn get_prerequisites(&self) -> Vec<Resource> {
|
|
|
fn get_prerequisites(&self) -> Vec<Resource> {
|
|
|
vec![ Resource::new("dir", self.get_path().parent().unwrap().to_string_lossy() ) ]
|
|
|
|
|
|
|
|
|
vec![ Resource::new("dir", self.path.parent().unwrap().to_string_lossy() ) ]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
fn as_action<'b>(&'b self, runner: &'b SymbolRunner) -> Box<Action + 'b> {
|
|
|
fn as_action<'b>(&'b self, runner: &'b SymbolRunner) -> Box<Action + 'b> {
|
|
|