From 80421e4619b354f0a8f6d43393c2f746001267e9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 12 Sep 2017 13:09:16 +0200 Subject: [PATCH] Build fix for OpenSSL < 1.0.2 refs #5450 --- lib/cli/calistcommand.cpp | 7 ++++--- lib/remote/pkiutility.cpp | 13 +++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/cli/calistcommand.cpp b/lib/cli/calistcommand.cpp index e44717188..fff0115d0 100644 --- a/lib/cli/calistcommand.cpp +++ b/lib/cli/calistcommand.cpp @@ -62,15 +62,16 @@ int CAListCommand::Run(const boost::program_options::variables_map& vm, const st else { ObjectLock olock(requests); - std::cout << "Fingerprint | Timestamp | Signed | Subject\n"; - std::cout << "-----------------------------------------------------------------|---------------------|--------|--------\n"; + std::cout << "Fingerprint | Timestamp | Signed | Subject\n"; + std::cout << "-----------------------------------------------------------------|--------------------------|--------|--------\n"; for (auto& kv : requests) { Dictionary::Ptr request = kv.second; std::cout << kv.first << " | " - << Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", request->Get("timestamp")) +/* << Utility::FormatDateTime("%Y/%m/%d %H:%M:%S", request->Get("timestamp")) */ + << request->Get("timestamp") << " | " << (request->Contains("cert_response") ? "*" : " ") << " " << " | " diff --git a/lib/remote/pkiutility.cpp b/lib/remote/pkiutility.cpp index c3d991755..6e8443bd5 100644 --- a/lib/remote/pkiutility.cpp +++ b/lib/remote/pkiutility.cpp @@ -393,6 +393,7 @@ static void CollectRequestHandler(const Dictionary::Ptr& requests, const String& boost::shared_ptr certRequest = StringToCertificate(certRequestText); +/* XXX (requires OpenSSL >= 1.0.0) time_t now; time(&now); ASN1_TIME *tm = ASN1_TIME_adj(NULL, now, 0, 0); @@ -400,15 +401,23 @@ static void CollectRequestHandler(const Dictionary::Ptr& requests, const String& int day, sec; ASN1_TIME_diff(&day, &sec, tm, X509_get_notBefore(certRequest.get())); - result->Set("timestamp", static_cast(now) + day * 24 * 60 * 60 + sec); + result->Set("timestamp", static_cast(now) + day * 24 * 60 * 60 + sec); */ BIO *out = BIO_new(BIO_s_mem()); - X509_NAME_print_ex(out, X509_get_subject_name(certRequest.get()), 0, XN_FLAG_ONELINE & ~ASN1_STRFLGS_ESC_MSB); + ASN1_TIME_print(out, X509_get_notBefore(certRequest.get())); char *data; long length; length = BIO_get_mem_data(out, &data); + result->Set("timestamp", String(data, data + length)); + BIO_free(out); + + out = BIO_new(BIO_s_mem()); + X509_NAME_print_ex(out, X509_get_subject_name(certRequest.get()), 0, XN_FLAG_ONELINE & ~ASN1_STRFLGS_ESC_MSB); + + length = BIO_get_mem_data(out, &data); + result->Set("subject", String(data, data + length)); BIO_free(out); -- 2.40.0