11 #ifndef _SMING_CORE_NETWORK_SSL_KEY_CERT_PAIR_H_ 12 #define _SMING_CORE_NETWORK_SSL_KEY_CERT_PAIR_H_ 24 return key && certificate;
36 bool assign(
const uint8_t* newKey,
unsigned newKeyLength,
const uint8_t* newCertificate,
37 unsigned newCertificateLength,
const char* newKeyPassword =
nullptr)
41 if(newKeyLength != 0 && newKey !=
nullptr) {
45 memcpy(key.begin(), newKey, newKeyLength);
48 if(newCertificateLength != 0 && newCertificate !=
nullptr) {
49 if(!certificate.
setLength(newCertificateLength)) {
52 memcpy(certificate.begin(), newCertificate, newCertificateLength);
55 unsigned passwordLength = (newKeyPassword ==
nullptr) ? 0 : strlen(newKeyPassword);
56 if(passwordLength != 0) {
57 keyPassword.setString(newKeyPassword, passwordLength);
74 return (key == keyCert.key) && (keyPassword == keyCert.keyPassword) && (certificate == keyCert.certificate);
80 keyPassword =
nullptr;
81 certificate =
nullptr;
84 const uint8_t* getKey()
86 return reinterpret_cast<const uint8_t*
>(key.c_str());
89 unsigned getKeyLength()
94 const char* getKeyPassword()
96 return keyPassword.c_str();
99 const uint8_t* getCertificate()
101 return reinterpret_cast<const uint8_t*
>(certificate.c_str());
104 unsigned getCertificateLength()
106 return certificate.length();
bool setLength(unsigned int length)
set the string length accordingly, expanding if necessary
bool assign(const SslKeyCertPair &keyCert)
Assign another certificate to this structure.
Definition: SslKeyCertPair.h:71
The string class.
Definition: WString.h:104
bool assign(const uint8_t *newKey, unsigned newKeyLength, const uint8_t *newCertificate, unsigned newCertificateLength, const char *newKeyPassword=nullptr)
Create certificate using provided values.
Definition: SslKeyCertPair.h:36
Class to manage an SSL key certificate with optional password.
Definition: SslKeyCertPair.h:19