CCF
Loading...
Searching...
No Matches
x509_time.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
7
8#include <openssl/asn1.h>
9
11{
15 static inline bool validate_chronological_times(
16 const Unique_X509_TIME& time_before,
17 const Unique_X509_TIME& time_after,
18 const std::optional<uint32_t>& allowed_diff_days = std::nullopt)
19 {
20 int diff_days = 0;
21 int diff_secs = 0;
22 CHECK1(ASN1_TIME_diff(&diff_days, &diff_secs, time_before, time_after));
23
24 return (diff_days > 0 || diff_secs > 0) &&
25 (!allowed_diff_days.has_value() ||
26 (unsigned int)diff_days <= allowed_diff_days.value());
27 }
28
29 static inline std::string to_x509_time_string(const ASN1_TIME* time)
30 {
31 std::tm t;
32 CHECK1(ASN1_TIME_to_tm(time, &t));
33 return ccf::ds::to_x509_time_string(t);
34 }
35}
Definition openssl_wrappers.h:29
void CHECK1(int rc)
Throws if rc is not 1 and has error.
Definition openssl_wrappers.h:58