Skip to main content

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

MemberDescription
TEKeyCertUtil()The TEKeyCertUtil constructor is the default class constructor.
TEKeyCertUtil(const TEKeyCertUtil &)The TEKeyCertUtil constructor copies a TEKeyCertUtil object.

Public Member Functions

MemberDescription
~TEKeyCertUtil()The TEKeyCertUtil destructor is the class destructor.

Static Public Member Functions

MemberDescription
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

ParameterDescription
filenameA string representing the file name of the PKCS -8 file. Must be a DER (binary) encoded.
passwordA string representing the password.
encodeA 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

ParameterDescription
filenameA string representing the file name of the PKCS -7 file. Must be a PEM encoded base 64 file
encodeA 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

ParameterDescription
filenameA string representing the file name of the PKCS -12 file. Must be a DER (binary) encoded.
passwordA string representing the password.
certificateA string representing the certificate chain. Set string certificate = "";
privatekeyA string representing the private key. Set string strPrivKey = "";
encodeA 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

ParameterDescription
serverA string representing the name or IP address of the Key Server.
portAn integer representing the port number of the TLS port.
certificateString of certificate
privatekeyString of private key