Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bcp-003-03 Certificate Provisioning support #377

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Fix Ubuntu 14.04 build
lo-simon committed Mar 6, 2024
commit 5002761c90149dc49156b5a0c23cf6fe64df93ab
20 changes: 12 additions & 8 deletions Development/nmos/est_utils.cpp
Original file line number Diff line number Diff line change
@@ -4,10 +4,12 @@
#include <sstream>
#include <string.h>
#include <boost/algorithm/string.hpp> // for boost::split
#include "openssl/err.h"
#include "openssl/rsa.h"
#include "openssl/pem.h"
#include "openssl/x509v3.h" // for X509V3_EXT_conf_nid
#include <openssl/asn1.h>
#include <openssl/err.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h> // for X509V3_EXT_conf_nid

namespace nmos
{
@@ -150,21 +152,19 @@ namespace nmos
{
throw est_exception("failed to get notAfter: X509_get0_notAfter failure: " + last_openssl_error());
}
time_t not_before_time;
time_t not_after_time;
#if (OPENSSL_VERSION_NUMBER >= 0x1010100fL)
tm not_before_tm;
if (!ASN1_TIME_to_tm(not_before, &not_before_tm))
{
throw est_exception("failed to convert notBefore ASN1_TIME to tm: ASN1_TIME_to_tm failure: " + last_openssl_error());
}
not_before_time = mktime(&not_before_tm);
auto not_before_time = mktime(&not_before_tm);
tm not_after_tm;
if (!ASN1_TIME_to_tm(not_after, &not_after_tm))
{
throw est_exception("failed to convert not_after ASN1_TIME to tm: ASN1_TIME_to_tm failure: " + last_openssl_error());
}
not_after_time = mktime(&not_after_tm);
auto not_after_time = mktime(&not_after_tm);
#else
// Construct another ASN1_TIME for the unix epoch, get the difference
// between them and use that to calculate a unix timestamp representing
@@ -491,7 +491,11 @@ namespace nmos
auto extensions = sk_X509_EXTENSION_new_null();
auto add_extension = [&extensions](int nid, const std::string& value)
{
#if OPENSSL_VERSION_NUMBER < 0x30000000L
auto extension = X509V3_EXT_conf_nid(NULL, NULL, nid, const_cast<char*>(value.c_str()));
#else
auto extension = X509V3_EXT_conf_nid(NULL, NULL, nid, value.c_str());
#endif
if (!extension)
{
std::stringstream ss;
1 change: 1 addition & 0 deletions Development/nmos/est_utils.h
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
#define NMOS_EST_UTILS_H

#include <stdexcept>
#include <string>
#include <vector>

namespace nmos