Skip to content

Commit 7bbd55a

Browse files
committed
serialize expires as secs
Refs rust-lang/rust#103332 If we don't want to lose precision here, we need to use nanos, but currently because of API disrepancy it's not possible.
1 parent 9fdb580 commit 7bbd55a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

webrtc/src/peer_connection/certificate.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl RTCCertificate {
131131
let mut bytes = [0u8; 8];
132132
bytes.copy_from_slice(&expires_pem.contents[..8]);
133133
let expires = if let Some(e) = SystemTime::UNIX_EPOCH
134-
.checked_add(Duration::from_nanos(u64::from_le_bytes(bytes)).into())
134+
.checked_add(Duration::from_secs(u64::from_le_bytes(bytes)).into())
135135
{
136136
e
137137
} else {
@@ -162,13 +162,15 @@ impl RTCCertificate {
162162
#[cfg(feature = "pem")]
163163
pub fn serialize_pem(&self) -> String {
164164
// Encode `expires` as a PEM block.
165+
//
166+
// TODO: serialize as nanos when https://github.com/rust-lang/rust/issues/103332 is fixed.
165167
let expires_pem = pem::Pem {
166168
tag: "EXPIRES".to_string(),
167169
contents: self
168170
.expires
169171
.duration_since(SystemTime::UNIX_EPOCH)
170172
.expect("expires to be valid")
171-
.as_nanos()
173+
.as_secs()
172174
.to_le_bytes()
173175
.to_vec(),
174176
};

0 commit comments

Comments
 (0)