PLCnext API Documentation  22.9.0.33
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Arp::System::Commons::Security::Certificate Class Reference

Class to handle x.509 certificates More...

#include <Certificate.hpp>

Inheritance diagram for Arp::System::Commons::Security::Certificate:
Inheritance graph

Public Member Functions

 Certificate (void)
 Constructs an empty Certificate instance to be loaded from file or memory. More...
 
 Certificate (const String &filename)
 Constructs an Certificate instance load from a file More...
 
 Certificate (const std::vector< byte > &pemOrDerEncoding)
 Constructs an Certificate instance load from memory More...
 
 Certificate (const Certificate &arg)
 Copy constructor. More...
 
virtual Certificateoperator= (const Certificate &arg)
 Assignment operator. More...
 
virtual ~Certificate (void)
 Destructs this instance and frees all resources. More...
 
 operator X509 * () const
 implicit conversion operator to openssl X509* More...
 
const StringGetFilename (void) const
 returns the filename were this x.509 certificate was loaded from More...
 
String GetSerialNumberHex (void) const
 returns the filename were this x.509 certificate was loaded from More...
 
String GetSubject (void) const
 returns the subject of the x.509 certificate as string (rfc2253 formatted) More...
 
String GetSubjectCommonName (void) const
 returns the common name of the subject More...
 
String GetSubjectSerialNumber (void) const
 return the serialnumber of the subject as string More...
 
String GetIssuer (void) const
 returns the issuer of the x.509 certificate as string (rfc2253 formatted) More...
 
String GetIssuerCommonName (void) const
 returns the common name of the issuer More...
 
const StringGetIdentifier (void) const
 returns an unique identifier for this certificate as string (sha256 hash of the x.509 certificate) More...
 
DateTime GetValidityNotBefore (void) const
 returns the notBefore field of the x.509 as DateTime object More...
 
Asn1Time GetValidityNotBeforeAsn1 (void) const
 returns the notBefore field of the x.509 as Asn1Time object More...
 
DateTime GetValidityNotAfter (void) const
 returns the notAfter field of the x.509 as DateTime object More...
 
Asn1Time GetValidityNotAfterAsn1 (void) const
 returns the notAfter field of the x.509 as Asn1Time object More...
 
std::vector< byteGetPemData (void) const
 returns the certificate encoded in PEM format More...
 
std::vector< byteGetDerData (void) const
 returns the certificate encoded in DER format More...
 
ItemInfo GetItemInfo (void) const
 returns ItemInfo for the Certificate More...
 
void LoadFromFile (const String &filename)
 loads the certificate from a file. File can be PEM or DER encoded More...
 
int LoadFromMemory (const std::vector< byte > &data, int offset=0)
 loads the certificate from memory. byte vector can be PEM or DER encoded More...
 
bool TryLoadFromMemory (const std::vector< byte > &data, int &offset)
 tries to load the certificate from memory. byte vector can be PEM or DER encoded More...
 
bool TryLoadFromBio (OpenSslBio &bio, int &offset)
 tries to load the certificate from OpenSslBio. More...
 
void SaveToFilePem (const String &filename) const
 saves the certificate in PEM format to filename More...
 
void AppendToFilePem (const String &filename) const
 appends the certificate in PEM format to filename More...
 
void SaveToFileDer (const String &filename) const
 saves the certificate in DER format to filename More...
 

Static Public Member Functions

static String Rfc2253Format (X509_NAME *name)
 static function to convert an openssl X509_NAME to an rfc2253 string More...
 
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 More...
 
static String HexString (ASN1_INTEGER *integer)
 static function convert an openssl ASN1_INTEGER to hexadecimal String representation More...
 

Protected Attributes

String identifier
 
X509 * internalCertificate
 

Detailed Description

Class to handle x.509 certificates

Constructor & Destructor Documentation

◆ Certificate() [1/4]

Arp::System::Commons::Security::Certificate::Certificate ( void  )

Constructs an empty Certificate instance to be loaded from file or memory.

◆ Certificate() [2/4]

Arp::System::Commons::Security::Certificate::Certificate ( const String filename)

Constructs an Certificate instance load from a file

◆ Certificate() [3/4]

Arp::System::Commons::Security::Certificate::Certificate ( const std::vector< byte > &  pemOrDerEncoding)

Constructs an Certificate instance load from memory

◆ Certificate() [4/4]

Arp::System::Commons::Security::Certificate::Certificate ( const Certificate arg)

Copy constructor.

◆ ~Certificate()

virtual Arp::System::Commons::Security::Certificate::~Certificate ( void  )
virtual

Destructs this instance and frees all resources.

Member Function Documentation

◆ AppendToFilePem()

void Arp::System::Commons::Security::Certificate::AppendToFilePem ( const String filename) const

appends the certificate in PEM format to filename

◆ GetAttributeValueByNid()

static String Arp::System::Commons::Security::Certificate::GetAttributeValueByNid ( X509_NAME *  name,
int  nid 
)
static

static function to extract an attribute value out of an openssl X509_NAME object identified by NID

Parameters
namepointer to the openssl X509_NAME object where the attribute value should be extracted from
nidnid of the attribute which should be extracted
Returns
extracted attribute as string

◆ GetDerData()

std::vector<byte> Arp::System::Commons::Security::Certificate::GetDerData ( void  ) const

returns the certificate encoded in DER format

◆ GetFilename()

const String & Arp::System::Commons::Security::Certificate::GetFilename ( void  ) const
inline

returns the filename were this x.509 certificate was loaded from

Returns
the filename were this x.509 certificate was loaded from

◆ GetIdentifier()

const String& Arp::System::Commons::Security::Certificate::GetIdentifier ( void  ) const

returns an unique identifier for this certificate as string (sha256 hash of the x.509 certificate)

◆ GetIssuer()

String Arp::System::Commons::Security::Certificate::GetIssuer ( void  ) const

returns the issuer of the x.509 certificate as string (rfc2253 formatted)

◆ GetIssuerCommonName()

String Arp::System::Commons::Security::Certificate::GetIssuerCommonName ( void  ) const

returns the common name of the issuer

◆ GetItemInfo()

ItemInfo Arp::System::Commons::Security::Certificate::GetItemInfo ( void  ) const

returns ItemInfo for the Certificate

◆ GetPemData()

std::vector<byte> Arp::System::Commons::Security::Certificate::GetPemData ( void  ) const

returns the certificate encoded in PEM format

◆ GetSerialNumberHex()

String Arp::System::Commons::Security::Certificate::GetSerialNumberHex ( void  ) const

returns the filename were this x.509 certificate was loaded from

◆ GetSubject()

String Arp::System::Commons::Security::Certificate::GetSubject ( void  ) const

returns the subject of the x.509 certificate as string (rfc2253 formatted)

◆ GetSubjectCommonName()

String Arp::System::Commons::Security::Certificate::GetSubjectCommonName ( void  ) const

returns the common name of the subject

◆ GetSubjectSerialNumber()

String Arp::System::Commons::Security::Certificate::GetSubjectSerialNumber ( void  ) const

return the serialnumber of the subject as string

◆ GetValidityNotAfter()

DateTime Arp::System::Commons::Security::Certificate::GetValidityNotAfter ( void  ) const

returns the notAfter field of the x.509 as DateTime object

◆ GetValidityNotAfterAsn1()

Asn1Time Arp::System::Commons::Security::Certificate::GetValidityNotAfterAsn1 ( void  ) const

returns the notAfter field of the x.509 as Asn1Time object

◆ GetValidityNotBefore()

DateTime Arp::System::Commons::Security::Certificate::GetValidityNotBefore ( void  ) const

returns the notBefore field of the x.509 as DateTime object

◆ GetValidityNotBeforeAsn1()

Asn1Time Arp::System::Commons::Security::Certificate::GetValidityNotBeforeAsn1 ( void  ) const

returns the notBefore field of the x.509 as Asn1Time object

◆ HexString()

static String Arp::System::Commons::Security::Certificate::HexString ( ASN1_INTEGER *  integer)
static

static function convert an openssl ASN1_INTEGER to hexadecimal String representation

Parameters
integerpointer to the openssl ASN1_INTEGER object which should be converted to hexadecimal string representation
Returns
the hexadecimal representation of integer as String

◆ LoadFromFile()

void Arp::System::Commons::Security::Certificate::LoadFromFile ( const String filename)

loads the certificate from a file. File can be PEM or DER encoded

◆ LoadFromMemory()

int Arp::System::Commons::Security::Certificate::LoadFromMemory ( const std::vector< byte > &  data,
int  offset = 0 
)

loads the certificate from memory. byte vector can be PEM or DER encoded

◆ operator X509 *()

Arp::System::Commons::Security::Certificate::operator X509 * ( ) const
inline

implicit conversion operator to openssl X509*

◆ operator=()

virtual Certificate& Arp::System::Commons::Security::Certificate::operator= ( const Certificate arg)
virtual

Assignment operator.

◆ Rfc2253Format()

static String Arp::System::Commons::Security::Certificate::Rfc2253Format ( X509_NAME *  name)
static

static function to convert an openssl X509_NAME to an rfc2253 string

◆ SaveToFileDer()

void Arp::System::Commons::Security::Certificate::SaveToFileDer ( const String filename) const

saves the certificate in DER format to filename

◆ SaveToFilePem()

void Arp::System::Commons::Security::Certificate::SaveToFilePem ( const String filename) const

saves the certificate in PEM format to filename

◆ TryLoadFromBio()

bool Arp::System::Commons::Security::Certificate::TryLoadFromBio ( OpenSslBio bio,
int &  offset 
)

tries to load the certificate from OpenSslBio.

Returns
true if the certificate could be loaded false if the certificate could not be loaded

◆ TryLoadFromMemory()

bool Arp::System::Commons::Security::Certificate::TryLoadFromMemory ( const std::vector< byte > &  data,
int &  offset 
)

tries to load the certificate from memory. byte vector can be PEM or DER encoded

Returns
true if the certificate could be loaded false if the certificate could not be loaded

The documentation for this class was generated from the following file: