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
49 operator X509*()
const;
160 void generateIdentifier(
void);
164 X509* internalCertificate;
175inline Certificate::operator X509*()
const
177 return this->internalCertificate;
182 return this->filename;
The class contains date and time informations.
Definition: DateTime.hpp:46
Definition: Loggable.hxx:20
Helper class to handle ASN1Time objects in x.509 Certificates
Definition: Asn1Time.hpp:22
Class to handle x.509 certificates
Definition: Certificate.hpp:25
virtual ~Certificate(void)
Destructs this instance and frees all resources.
DateTime GetValidityNotAfter(void) const
returns the notAfter field of the x.509 as DateTime object
Asn1Time GetValidityNotBeforeAsn1(void) const
returns the notBefore field of the x.509 as Asn1Time object
Certificate(const std::vector< byte > &pemOrDerEncoding)
Constructs an Certificate instance load from memory
bool TryLoadFromMemory(const std::vector< byte > &data, int &offset)
tries to load the certificate from memory. byte vector can be PEM or DER encoded
void AppendToFilePem(const String &filename) const
appends the certificate in PEM format to filename
static String Rfc2253Format(X509_NAME *name)
static function to convert an openssl X509_NAME to an rfc2253 string
Certificate(const String &filename)
Constructs an Certificate instance load from a file
String GetSerialNumberHex(void) const
returns the filename were this x.509 certificate was loaded from
String GetSubjectCommonName(void) const
returns the common name of the subject
void SaveToFilePem(const String &filename) const
saves the certificate in PEM format to filename
void SaveToFileDer(const String &filename) const
saves the certificate in DER format to filename
virtual Certificate & operator=(const Certificate &arg)
Assignment operator.
ItemInfo GetItemInfo(void) const
returns ItemInfo for the Certificate
bool TryLoadFromBio(OpenSslBio &bio, int &offset)
tries to load the certificate from OpenSslBio.
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
String GetSubjectSerialNumber(void) const
return the serialnumber of the subject as string
std::vector< byte > GetPemData(void) const
returns the certificate encoded in PEM format
int LoadFromMemory(const std::vector< byte > &data, int offset=0)
loads the certificate from memory. byte vector can be PEM or DER encoded
String GetSubject(void) const
returns the subject of the x.509 certificate as string (rfc2253 formatted)
DateTime GetValidityNotBefore(void) const
returns the notBefore field of the x.509 as DateTime object
Certificate(void)
Constructs an empty Certificate instance to be loaded from file or memory.
std::vector< byte > GetDerData(void) const
returns the certificate encoded in DER format
void LoadFromFile(const String &filename)
loads the certificate from a file. File can be PEM or DER encoded
Asn1Time GetValidityNotAfterAsn1(void) const
returns the notAfter field of the x.509 as Asn1Time object
String GetIssuerCommonName(void) const
returns the common name of the issuer
const String & GetFilename(void) const
returns the filename were this x.509 certificate was loaded from
Definition: Certificate.hpp:180
static String HexString(ASN1_INTEGER *integer)
static function convert an openssl ASN1_INTEGER to hexadecimal String representation
String GetIssuer(void) const
returns the issuer of the x.509 certificate as string (rfc2253 formatted)
const String & GetIdentifier(void) const
returns an unique identifier for this certificate as string (sha256 hash of the x....
Certificate(const Certificate &arg)
Copy constructor.
Definition: OpenSslBio.hpp:14
Definition: ItemInfo.hpp:12
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API