PLCnext API Documentation 24.0.0.71
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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.
 
 Certificate (const String &filename)
 Constructs an Certificate instance load from a file
 
 Certificate (const std::vector< byte > &pemOrDerEncoding)
 Constructs an Certificate instance load from memory
 
 Certificate (X509 *cert)
 
 Certificate (const Certificate &arg)
 Copy constructor.
 
 Certificate (Certificate &&arg) noexcept
 
virtual Certificateoperator= (const Certificate &arg)
 Assignment operator.
 
Certificateoperator= (Certificate &&arg) noexcept
 
virtual ~Certificate (void)
 Destructs this instance and frees all resources.
 
 operator X509 * () const
 implicit conversion operator to openssl X509*
 
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
 
String GetSubject (void) const
 returns the subject of the x.509 certificate as string (rfc2253 formatted)
 
String GetSubjectCommonName (void) const
 returns the common name of the subject
 
String GetSubjectSerialNumber (void) const
 return the serialnumber of the subject as string
 
String GetIssuer (void) const
 returns the issuer of the x.509 certificate as string (rfc2253 formatted)
 
String GetIssuerCommonName (void) const
 returns the common name of the issuer
 
const StringGetIdentifier (void) const
 returns an unique identifier for this certificate as string (sha256 hash of the x.509 certificate)
 
DateTime GetValidityNotBefore (void) const
 returns the notBefore field of the x.509 as DateTime object
 
Asn1Time GetValidityNotBeforeAsn1 (void) const
 returns the notBefore field of the x.509 as Asn1Time object
 
DateTime GetValidityNotAfter (void) const
 returns the notAfter field of the x.509 as DateTime object
 
Asn1Time GetValidityNotAfterAsn1 (void) const
 returns the notAfter field of the x.509 as Asn1Time object
 
std::vector< byteGetPemData (void) const
 returns the certificate encoded in PEM format
 
std::vector< byteGetDerData (void) const
 returns the certificate encoded in DER format
 
ItemInfo GetItemInfo (void) const
 returns ItemInfo for the Certificate
 
void LoadFromFile (const String &filename)
 loads the certificate from a file. File can be PEM or DER encoded
 
int LoadFromMemory (const std::vector< byte > &data, int offset=0)
 loads the certificate from memory. byte vector can be PEM or DER encoded
 
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
 
void AppendToFilePem (const String &filename) const
 appends the certificate in PEM format to filename
 
void SaveToFileDer (const String &filename) const
 saves the certificate in DER format to filename
 

Static Public Member Functions

static String Rfc2253Format (X509_NAME *name)
 static function to convert an openssl X509_NAME to an rfc2253 string
 
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

Member Function Documentation

◆ 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

◆ 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

◆ 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

◆ 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: