adamdebreceni commented on code in PR #1336:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1336#discussion_r876908856


##########
libminifi/src/utils/tls/CertificateUtils.cpp:
##########
@@ -116,6 +143,110 @@ EVP_PKEY_unique_ptr extractPrivateKey(const 
PCCERT_CONTEXT certificate) {
 }
 #endif  // WIN32
 
+std::string getLatestOpenSSLErrorString() {
+  unsigned long err = ERR_peek_last_error(); // NOLINT
+  if (err == 0U) {
+    return "";
+  }
+  char buf[4096];
+  ERR_error_string_n(err, buf, sizeof(buf));
+  return buf;
+}
+
+std::optional<std::chrono::system_clock::time_point> 
getCertificateExpiration(const X509_unique_ptr& cert) {
+  const ASN1_TIME* asn1_end = X509_get0_notAfter(cert.get());
+  if (!asn1_end) {
+    return {};
+  }
+  std::tm end{};
+  int ret = ASN1_time_parse(reinterpret_cast<const char*>(asn1_end->data), 
asn1_end->length, &end, 0);
+  if (ret == -1) {
+    return {};
+  }
+  return std::chrono::system_clock::from_time_t(std::mktime(&end));

Review Comment:
   changed it to `utils::mkgmtime`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to