Skip to content

Commit

Permalink
Stop using libc::time_t
Browse files Browse the repository at this point in the history
This type was used for the calculation of the certificate's expiration
delay, which causes troubles on some 32 bits systems.
Rel #59
  • Loading branch information
breard-r committed May 7, 2022
1 parent 01894bc commit 0d1fddd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- An invalid reference in the command line arguments has been fixed.
- Some missing file path in log messages has been added.
- The calculation of the certificate's expiration delay does no longer break compilation on some systems.


## [0.19.0] - 2022-04-17
Expand Down
1 change: 0 additions & 1 deletion acme_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ base64 = "0.13"
daemonize = "0.4"
env_logger = "0.9"
glob = "0.3"
libc = "0.2"
log = "0.4"
native-tls = "0.2"
openssl = { version = "0.10", optional = true }
Expand Down
5 changes: 2 additions & 3 deletions acme_common/src/crypto/openssl_certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use openssl::x509::extension::{BasicConstraints, SubjectAlternativeName};
use openssl::x509::{X509Builder, X509Extension, X509NameBuilder, X509Req, X509ReqBuilder, X509};
use std::collections::{HashMap, HashSet};
use std::net::IpAddr;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::time::Duration;

fn get_digest(digest: HashFunction, key_pair: &KeyPair) -> MessageDigest {
#[cfg(not(any(ed25519, ed448)))]
Expand Down Expand Up @@ -109,8 +109,7 @@ impl X509Certificate {
}

pub fn expires_in(&self) -> Result<Duration, Error> {
let timestamp = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() as libc::time_t;
let now = Asn1Time::from_unix(timestamp)?;
let now = Asn1Time::days_from_now(0)?;
let not_after = self.inner_cert.not_after();
let diff = now.diff(not_after)?;
let nb_secs = diff.days * 24 * 60 * 60 + diff.secs;
Expand Down

0 comments on commit 0d1fddd

Please sign in to comment.