8#include "Arp/System/Commons/Logging.h"
9#include "Arp/System/Commons/Security/Asn1Time.hpp"
10#include "Arp/System/Commons/Security/ItemInfo.hpp"
11#include "Arp/System/Commons/Security/Internal/OpenSslBio.hpp"
15#include <openssl/x509.h>
16#include <openssl/x509v3.h>
18using namespace Arp::System::Commons::Security::Internal;
20namespace Arp {
namespace System {
namespace Commons {
namespace Security
29 Certificate(
const std::vector<byte>& pemOrDerEncoding);
41 operator X509*()
const;
79 void generateIdentifier(
void);
83 X509* internalCertificate;
This class contains date and time informations.
Definition: DateTime.hpp:27
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Derive from this class to inherit logging functionality.
Definition: Loggable.hxx:28
Helper class to handle ASN1Time objects in x.509 Certificates
Definition: Asn1Time.hpp:21
Class to handle x.509 certificates
Definition: Certificate.hpp:25
static String Rfc2253Format(X509_NAME *name)
static function to convert an openssl X509_NAME to an rfc2253 string
Definition: Certificate.cpp:377
static String HexString(ASN1_INTEGER *integer)
static function convert an openssl ASN1_INTEGER to hexadecimal String representation
Definition: Certificate.cpp:355
DateTime GetValidityNotAfter(void) const
returns the notAfter field of the x.509 as DateTime object
Definition: Certificate.cpp:464
Asn1Time GetValidityNotBeforeAsn1(void) const
returns the notBefore field of the x.509 as Asn1Time object
Definition: Certificate.cpp:457
static String GetAttributeValueByNid(X509_NAME *name, int nid)
static function to extract an attribute value out of an openssl X509_NAME object identified by NID
Definition: Certificate.cpp:427
bool TryLoadFromMemory(const std::vector< byte > &data, int &offset)
tries to load the certificate from memory. byte vector can be PEM or DER encoded
Definition: Certificate.cpp:161
void AppendToFilePem(const String &filename) const
appends the certificate in PEM format to filename
Definition: Certificate.cpp:254
String GetSerialNumberHex(void) const
returns the filename were this x.509 certificate was loaded from
Definition: Certificate.cpp:342
String GetSubjectCommonName(void) const
returns the common name of the subject
Definition: Certificate.cpp:390
void SaveToFilePem(const String &filename) const
saves the certificate in PEM format to filename
Definition: Certificate.cpp:239
void SaveToFileDer(const String &filename) const
saves the certificate in DER format to filename
Definition: Certificate.cpp:269
ItemInfo GetItemInfo(void) const
returns ItemInfo for the Certificate
Definition: Certificate.cpp:543
bool TryLoadFromBio(OpenSslBio &bio, int &offset)
tries to load the certificate from OpenSslBio.
Definition: Certificate.cpp:216
String GetSubjectSerialNumber(void) const
return the serialnumber of the subject as string
Definition: Certificate.cpp:397
Certificate & operator=(const Certificate &arg)
Assignment operator.
Definition: Certificate.cpp:90
std::vector< byte > GetPemData(void) const
returns the certificate encoded in PEM format
Definition: Certificate.cpp:499
int LoadFromMemory(const std::vector< byte > &data, int offset=0)
loads the certificate from memory. byte vector can be PEM or DER encoded
Definition: Certificate.cpp:197
String GetSubject(void) const
returns the subject of the x.509 certificate as string (rfc2253 formatted)
Definition: Certificate.cpp:370
DateTime GetValidityNotBefore(void) const
returns the notBefore field of the x.509 as DateTime object
Definition: Certificate.cpp:451
virtual ~Certificate(void)
Destructs this instance and frees all resources.
Definition: Certificate.cpp:67
Certificate(void)
Constructs an empty Certificate instance to be loaded from file or memory.
Definition: Certificate.cpp:26
std::vector< byte > GetDerData(void) const
returns the certificate encoded in DER format
Definition: Certificate.cpp:521
void LoadFromFile(const String &filename)
loads the certificate from a file. File can be PEM or DER encoded
Definition: Certificate.cpp:124
Asn1Time GetValidityNotAfterAsn1(void) const
returns the notAfter field of the x.509 as Asn1Time object
Definition: Certificate.cpp:470
String GetIssuerCommonName(void) const
returns the common name of the issuer
Definition: Certificate.cpp:411
const String & GetFilename(void) const
returns the filename were this x.509 certificate was loaded from
Definition: Certificate.cpp:336
String GetIssuer(void) const
returns the issuer of the x.509 certificate as string (rfc2253 formatted)
Definition: Certificate.cpp:404
const String & GetIdentifier(void) const
returns an unique identifier for this certificate as string (sha256 hash of the x....
Definition: Certificate.cpp:476
Definition: OpenSslBio.hpp:14
Definition: ItemInfo.hpp:12
Root namespace for the PLCnext API