Browse Source

Stop using `libc::time_t`

This type was used for the calculation of the certificate's expiration
delay, which causes troubles on some 32 bits systems.
Rel #59
pull/62/head
Rodolphe Bréard 3 years ago
parent
commit
0d1fddd9d4
  1. 1
      CHANGELOG.md
  2. 1
      acme_common/Cargo.toml
  3. 5
      acme_common/src/crypto/openssl_certificate.rs

1
CHANGELOG.md

@ -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

1
acme_common/Cargo.toml

@ -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 }

5
acme_common/src/crypto/openssl_certificate.rs

@ -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)))]
@ -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;

Loading…
Cancel
Save