ERUCES::TEKeyCertUtil
#include <teutil_keycert.h>
TEKeyCertUtil is an helper class which is used for certificate user connection to the Key Service.
The loadFromFile method is used to read the certificate and private key from file which can be used to create a SSLMutualConnection to the Key Service. Use with TEConnection::createInstance(TEConnection::SSLMutualConnection);
Private Func
| Member | Description |
|---|---|
TEKeyCertUtil() | The TEKeyCertUtil constructor is the default class constructor. |
TEKeyCertUtil(const TEKeyCertUtil &) | The TEKeyCertUtil constructor copies a TEKeyCertUtil object. |
Public Member Functions
| Member | Description |
|---|---|
~TEKeyCertUtil() | The TEKeyCertUtil destructor is the class destructor. |
Static Public Member Functions
| Member | Description |
|---|---|
const _TESTD string loadFromFile(_TESTD string filename, _TESTD string password, bool encode=true) | The loadFromFile method loads a private key from a PKCS -8 file (DER encode binary file). |
const _TESTD string loadFromFile(_TESTD string filename, bool encode=true) | The loadFromFile method loads a certificate from a PKCS -7 file (PEM encoded base 64 file). |
void loadFromFile(_TESTD string filename, _TESTD string password, _TESTD string &certificate, _TESTD string &privatekey, bool encode=true) | The loadFromFile method loads a private key and a certificate from a PKCS -12 file (DER encode binary file). |
void verifyCertificateAndKey(_TESTD string server, uint32_t port, _TESTD string &certificate, _TESTD string &privatekey) | The verifyCertificateAndKey method validates provided certificate and private key with provided TLS server. |
Member Function Documentation
TEKeyCertUtil()
The TEKeyCertUtil constructor is the default class constructor.
TEKeyCertUtil(const TEKeyCertUtil &)
The TEKeyCertUtil constructor copies a TEKeyCertUtil object.
~TEKeyCertUtil()
The TEKeyCertUtil destructor is the class destructor.
const _TESTD string loadFromFile(_TESTD string filename, _TESTD string password, bool encode=true)
The loadFromFile method loads a private key from a PKCS -8 file (DER encode binary file).
Parameters
| Parameter | Description |
|---|---|
filename | A string representing the file name of the PKCS -8 file. Must be a DER (binary) encoded. |
password | A string representing the password. |
encode | A boolean representing the return encode method. True- return a Base64 encoded value. |
Returns: A string representing the private key.
const _TESTD string loadFromFile(_TESTD string filename, bool encode=true)
The loadFromFile method loads a certificate from a PKCS -7 file (PEM encoded base 64 file).
Parameters
| Parameter | Description |
|---|---|
filename | A string representing the file name of the PKCS -7 file. Must be a PEM encoded base 64 file |
encode | A boolean representing the return encode method. True- return a Base64 encoded value. |
Returns: A string representing the private key.
void loadFromFile(_TESTD string filename, _TESTD string password, _TESTD string &certificate, _TESTD string &privatekey, bool encode=true)
The loadFromFile method loads a private key and a certificate from a PKCS -12 file (DER encode binary file).
Parameters
| Parameter | Description |
|---|---|
filename | A string representing the file name of the PKCS -12 file. Must be a DER (binary) encoded. |
password | A string representing the password. |
certificate | A string representing the certificate chain. Set string certificate = ""; |
privatekey | A string representing the private key. Set string strPrivKey = ""; |
encode | A boolean representing the return encode method. True- return a Base64 encoded value. |
void verifyCertificateAndKey(_TESTD string server, uint32_t port, _TESTD string &certificate, _TESTD string &privatekey)
The verifyCertificateAndKey method validates provided certificate and private key with provided TLS server.
Parameters
| Parameter | Description |
|---|---|
server | A string representing the name or IP address of the Key Server. |
port | An integer representing the port number of the TLS port. |
certificate | String of certificate |
privatekey | String of private key |