PLCnext API Documentation 25.0.2.69
Public Types | Public Member Functions | List of all members
Arp::System::Commons::Security::IdentityStore Class Reference

Class with represents a Identity (Certificate with Chain and private Key) and is able to initialize an OpenSSL SSL Context This is an internal class used by TlsSocket More...

#include <IdentityStore.hpp>

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

Public Types

enum  KeyMustExist : bool { IgnoreMissingKey = false , RequireKeyExists = true }
 Enum which dicates if the key in the IdentityStore must exist or if this can be ignored
 

Public Member Functions

 IdentityStore (const String &basePath, const String &name, KeyMustExist requireKeyExists=RequireKeyExists)
 Constructs an IdentityStore instance.
 
 IdentityStore (const IdentityStore &arg)=delete
 Copy constructor.
 
IdentityStoreoperator= (const IdentityStore &arg)=delete
 Assignment operator.
 
 ~IdentityStore (void)=default
 Destructs this instance and frees all resources.
 
String GetName (void) const
 Returns the name of the IdentityStore
 
String GetFullCertificateFileName (void) const
 Returns the absolute path to the certificate file
 
String GetFullKeyFileName (void) const
 Returns the absolute path to the key file
 
String GetFullTpmKeyFileName (void) const
 Returns the absolute path to the tpm key file
 
bool HasCertificate (void)
 checks if a certificate is available for this IdentityStore
 
const std::shared_ptr< KeyPair > & GetKeyPair (void)
 Returns a shared_ptr to the KeyPair of this IdentityStore
 
KeyPairType GetKeyType (void)
 Returns the type of the key pair
 
void InitSslContext (SSL_CTX *pSslCtx) const
 Initializes a OpenSSL SSL_CTX Structure with the private key and certificate More...
 
std::vector< byte > GetPublicKey (void)
 Reads the public key in PEM format More...
 
SecurityConfigurationError SetKeyPair (const std::vector< byte > &pemData)
 Sets or overwrites the keypair from the PEM encoded given bytes More...
 
SecurityConfigurationError SetCertificate (const std::vector< byte > &pemData)
 Sets or overwrites the certificate from the PEM encoded given bytes More...
 
std::vector< byte > GetPemCertificate (void)
 Gets the certificate as byte array in PEM format More...
 
const CertificateGetCertificate (void) const
 
const std::vector< Certificate > & GetIssuerCertificates (void) const
 
std::vector< byte > GetDerCertificate (void)
 Gets the certificate as byte array in DER format More...
 
std::vector< byte > GetPemCertificateWithChain (void)
 Gets the certificate as byte array in PEM format with issuer certificates appended More...
 
std::vector< byte > GetDerCertificateWithChain (void)
 Get the certificate as byte array in DER format with issuer certificates appended More...
 
std::vector< std::vector< byte > > GetIssuerPemCertificates (void)
 Get the issuer certificates in PEM format
 
void CreateAllDirectories (void)
 Creates all needed directories inside the folder of this IdentityStore
 
SecurityConfigurationError ListContent (SecurityListType type, std::vector< ItemInfo > &result)
 Lists all elements in the list referenced by their SecurityListType More...
 
SecurityConfigurationError AddElement (SecurityListType type, const std::vector< byte > &pemData)
 Adds an element into the list referenced by SecurityListType More...
 
SecurityConfigurationError DeleteElement (SecurityListType type, const String &identifier)
 Delete an elements from the list referenced by ListType, identified by identifier More...
 
SecurityConfigurationError GenerateKeyPair (KeyPairType type)
 Generate a new KeyPair for this IdentityStore More...
 
std::vector< byte > GenerateCSR ()
 Generate a Certificate Signing Request (CSR) for the Key Pair of this IdentityStore More...
 
bool VerifyCertMatchesWithPrivateKey (void)
 Verifies if the certificates matches with the key pair More...
 

Detailed Description

Class with represents a Identity (Certificate with Chain and private Key) and is able to initialize an OpenSSL SSL Context This is an internal class used by TlsSocket

Member Function Documentation

◆ AddElement()

SecurityConfigurationError Arp::System::Commons::Security::IdentityStore::AddElement ( SecurityListType  type,
const std::vector< byte > &  pemData 
)

Adds an element into the list referenced by SecurityListType

Parameters
typeWhich contenttype should be listed
pemDataA vector of PEM encoded bytes for the element to be added
Returns
Arp::System::Commons::Security::SecurityConfigurationError::None if operation was successful. Otherwise a fitting error code.

◆ DeleteElement()

SecurityConfigurationError Arp::System::Commons::Security::IdentityStore::DeleteElement ( SecurityListType  type,
const String identifier 
)

Delete an elements from the list referenced by ListType, identified by identifier

Returns
Arp::System::Commons::Security::SecurityConfigurationError::None if operation was successful. Otherwise a fitting error code.

◆ GenerateCSR()

std::vector< byte > Arp::System::Commons::Security::IdentityStore::GenerateCSR ( void  )

Generate a Certificate Signing Request (CSR) for the Key Pair of this IdentityStore

Returns
byte vector with generated CSR in PEM format

◆ GenerateKeyPair()

SecurityConfigurationError Arp::System::Commons::Security::IdentityStore::GenerateKeyPair ( KeyPairType  type)

Generate a new KeyPair for this IdentityStore

Parameters
typeWhich key pair type should be generated

Not all targets support all key pairs

Returns
Arp::System::Commons::Security::SecurityConfigurationError::None if operation was successful. Otherwise a fitting error code.

◆ GetDerCertificate()

std::vector< byte > Arp::System::Commons::Security::IdentityStore::GetDerCertificate ( void  )

Gets the certificate as byte array in DER format

Returns
byte vector with DER encoded certificate

◆ GetDerCertificateWithChain()

std::vector< byte > Arp::System::Commons::Security::IdentityStore::GetDerCertificateWithChain ( void  )

Get the certificate as byte array in DER format with issuer certificates appended

Returns
byte vector with DER encoded certificate with all certificates from its chain appended

◆ GetPemCertificate()

std::vector< byte > Arp::System::Commons::Security::IdentityStore::GetPemCertificate ( void  )

Gets the certificate as byte array in PEM format

Returns
byte vector with PEM encoded certificate

◆ GetPemCertificateWithChain()

std::vector< byte > Arp::System::Commons::Security::IdentityStore::GetPemCertificateWithChain ( void  )

Gets the certificate as byte array in PEM format with issuer certificates appended

Returns
byte vector with PEM encoded certificate with all certificates from its chain appended

◆ GetPublicKey()

std::vector< byte > Arp::System::Commons::Security::IdentityStore::GetPublicKey ( void  )

Reads the public key in PEM format

Returns
byte vector with PEM encoded public key

◆ InitSslContext()

void Arp::System::Commons::Security::IdentityStore::InitSslContext ( SSL_CTX *  pSslCtx) const

Initializes a OpenSSL SSL_CTX Structure with the private key and certificate

Parameters
pSslCtxPointer to the OpenSSL SSL_CTX structure to initialize

◆ ListContent()

SecurityConfigurationError Arp::System::Commons::Security::IdentityStore::ListContent ( SecurityListType  type,
std::vector< ItemInfo > &  result 
)

Lists all elements in the list referenced by their SecurityListType

Parameters
typeWhich contenttype should be listed
resultA vector of ItemInfo in which the listed content is written to
Returns
Arp::System::Commons::Security::SecurityConfigurationError::None if operation was successful. Otherwise a fitting error code.

◆ SetCertificate()

SecurityConfigurationError Arp::System::Commons::Security::IdentityStore::SetCertificate ( const std::vector< byte > &  pemData)

Sets or overwrites the certificate from the PEM encoded given bytes

Parameters
pemDataA byte vector with the PEM encoded certificate
Returns
Arp::System::Commons::Security::SecurityConfigurationError::None if operation was successful. Otherwise a fitting error code.

◆ SetKeyPair()

SecurityConfigurationError Arp::System::Commons::Security::IdentityStore::SetKeyPair ( const std::vector< byte > &  pemData)

Sets or overwrites the keypair from the PEM encoded given bytes

Parameters
pemDataA byte vector with the PEM encoded key pair
Returns
Arp::System::Commons::Security::SecurityConfigurationError::None if operation was successful. Otherwise a fitting error code.

◆ VerifyCertMatchesWithPrivateKey()

bool Arp::System::Commons::Security::IdentityStore::VerifyCertMatchesWithPrivateKey ( void  )

Verifies if the certificates matches with the key pair

Returns
true if the certificate matches the private key, false otherwise

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