8#include "Arp/System/Commons/Logging.h" 
    9#include "Arp/System/Commons/Io/Path.hpp" 
   10#include "Arp/System/Commons/Security/KeyPair.hpp" 
   11#include "Arp/System/Commons/Security/Certificate.hpp" 
   12#include "Arp/System/Commons/Security/SecurityListType.hpp" 
   13#include "Arp/System/Commons/Security/ItemInfo.hpp" 
   14#include "Arp/System/Commons/Security/KeyPairType.hpp" 
   15#include "Arp/System/Commons/Security/SecurityConfigurationError.hpp" 
   18#include <openssl/evp.h> 
   20namespace Arp { 
namespace System { 
namespace Commons { 
namespace Security
 
   35        IgnoreMissingKey = 
false,
 
   36        RequireKeyExists = 
true 
   58    const std::shared_ptr<KeyPair>& 
GetKeyPair(
void);
 
   68    const std::vector<Certificate>& GetIssuerCertificates(
void) 
const;
 
   87    bool LoadSoftwareKeyPair();
 
   88    bool LoadHardwareKeyPair();
 
   89    void loadCertWithChain(
const String& file);
 
   90    void listIssuerList(std::vector<ItemInfo>& result);
 
   91    void listIdentityCert(std::vector<ItemInfo>& result);
 
   96    std::shared_ptr<KeyPair> keyPair;
 
   98    std::vector<Certificate> issuers;
 
  101    static const String CertificateFileName;
 
  102    static const String KeyFileName;
 
  103    static const String TpmKeyFileName;
 
  104    static const String DirectorySeparator;
 
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
 
Class to handle x.509 certificates
Definition: Certificate.hpp:25
 
Class with represents a Identity (Certificate with Chain and private Key) and is able to initialize a...
Definition: IdentityStore.hpp:28
 
void CreateAllDirectories(void)
Creates all needed directories inside the folder of this IdentityStore
Definition: IdentityStore.cpp:56
 
const std::shared_ptr< KeyPair > & GetKeyPair(void)
Returns a shared_ptr to the KeyPair of this IdentityStore
Definition: IdentityStore.cpp:661
 
String GetName(void) const
Returns the name of the IdentityStore
Definition: IdentityStore.cpp:687
 
SecurityConfigurationError GenerateKeyPair(KeyPairType type)
Generate a new KeyPair for this IdentityStore
Definition: IdentityStore.cpp:566
 
SecurityConfigurationError DeleteElement(SecurityListType type, const String &identifier)
Delete an elements from the list referenced by ListType, identified by identifier
Definition: IdentityStore.cpp:520
 
KeyMustExist
Enum which dicates if the key in the IdentityStore must exist or if this can be ignored
Definition: IdentityStore.hpp:34
 
SecurityConfigurationError SetKeyPair(const std::vector< byte > &pemData)
Sets or overwrites the keypair from the PEM encoded given bytes
Definition: IdentityStore.cpp:234
 
IdentityStore(const IdentityStore &arg)=delete
Copy constructor.
 
SecurityConfigurationError AddElement(SecurityListType type, const std::vector< byte > &pemData)
Adds an element into the list referenced by SecurityListType
Definition: IdentityStore.cpp:485
 
bool HasCertificate(void)
checks if a certificate is available for this IdentityStore
Definition: IdentityStore.cpp:655
 
std::vector< byte > GetPemCertificateWithChain(void)
Gets the certificate as byte array in PEM format with issuer certificates appended
Definition: IdentityStore.cpp:369
 
std::vector< byte > GetDerCertificateWithChain(void)
Get the certificate as byte array in DER format with issuer certificates appended
Definition: IdentityStore.cpp:391
 
void InitSslContext(SSL_CTX *pSslCtx) const
Initializes a OpenSSL SSL_CTX Structure with the private key and certificate
Definition: IdentityStore.cpp:187
 
String GetFullTpmKeyFileName(void) const
Returns the absolute path to the tpm key file
Definition: IdentityStore.cpp:705
 
std::vector< byte > GetPemCertificate(void)
Gets the certificate as byte array in PEM format
Definition: IdentityStore.cpp:327
 
std::vector< byte > GetPublicKey(void)
Reads the public key in PEM format
Definition: IdentityStore.cpp:226
 
SecurityConfigurationError SetCertificate(const std::vector< byte > &pemData)
Sets or overwrites the certificate from the PEM encoded given bytes
Definition: IdentityStore.cpp:286
 
KeyPairType GetKeyType(void)
Returns the type of the key pair
Definition: IdentityStore.cpp:711
 
std::vector< byte > GenerateCSR()
Generate a Certificate Signing Request (CSR) for the Key Pair of this IdentityStore
Definition: IdentityStore.cpp:615
 
String GetFullCertificateFileName(void) const
Returns the absolute path to the certificate file
Definition: IdentityStore.cpp:693
 
IdentityStore & operator=(const IdentityStore &arg)=delete
Assignment operator.
 
std::vector< std::vector< byte > > GetIssuerPemCertificates(void)
Get the issuer certificates in PEM format
Definition: IdentityStore.cpp:412
 
SecurityConfigurationError ListContent(SecurityListType type, std::vector< ItemInfo > &result)
Lists all elements in the list referenced by their SecurityListType
Definition: IdentityStore.cpp:428
 
bool VerifyCertMatchesWithPrivateKey(void)
Verifies if the certificates matches with the key pair
Definition: IdentityStore.cpp:668
 
std::vector< byte > GetDerCertificate(void)
Gets the certificate as byte array in DER format
Definition: IdentityStore.cpp:353
 
~IdentityStore(void)=default
Destructs this instance and frees all resources.
 
IdentityStore(const String &basePath, const String &name, KeyMustExist requireKeyExists=RequireKeyExists)
Constructs an IdentityStore instance.
Definition: IdentityStore.cpp:39
 
String GetFullKeyFileName(void) const
Returns the absolute path to the key file
Definition: IdentityStore.cpp:699
 
SecurityConfigurationError
Enumeration of possible error codes when interacting with classes in the Security namespace
Definition: SecurityConfigurationError.hpp:17
 
Root namespace for the PLCnext API