Skip to content

enable loading of root-CAs, certificates and keys from byte array... #2877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions libraries/ESP8266WiFi/src/WiFiClientSecure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,14 @@ bool WiFiClientSecure::loadCACert(Stream& stream, size_t size)
return _ssl->loadObject(SSL_OBJ_X509_CACERT, stream, size);
}

bool WiFiClientSecure::loadCACert(const uint8_t* pk, size_t size)
{
if (!_ssl) {
return false;
}
return _ssl->loadObject(SSL_OBJ_X509_CACERT, pk, size);
}

bool WiFiClientSecure::loadCertificate(Stream& stream, size_t size)
{
if (!_ssl) {
Expand All @@ -579,6 +587,14 @@ bool WiFiClientSecure::loadCertificate(Stream& stream, size_t size)
return _ssl->loadObject(SSL_OBJ_X509_CERT, stream, size);
}

bool WiFiClientSecure::loadCertificate(const uint8_t* pk, size_t size)
{
if (!_ssl) {
return false;
}
return _ssl->loadObject(SSL_OBJ_X509_CERT, pk, size);
}

bool WiFiClientSecure::loadPrivateKey(Stream& stream, size_t size)
{
if (!_ssl) {
Expand All @@ -587,6 +603,14 @@ bool WiFiClientSecure::loadPrivateKey(Stream& stream, size_t size)
return _ssl->loadObject(SSL_OBJ_RSA_KEY, stream, size);
}

bool WiFiClientSecure::loadPrivateKey(const uint8_t* pk, size_t size)
{
if (!_ssl) {
return false;
}
return _ssl->loadObject(SSL_OBJ_RSA_KEY, pk, size);
}

extern "C" int __ax_port_read(int fd, uint8_t* buffer, size_t count)
{
ClientContext* _client = SSLContext::getIOContext(fd);
Expand Down
3 changes: 3 additions & 0 deletions libraries/ESP8266WiFi/src/WiFiClientSecure.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ class WiFiClientSecure : public WiFiClient {
void setPrivateKey(const uint8_t* pk, size_t size);

bool loadCertificate(Stream& stream, size_t size);
bool loadCertificate(const uint8_t* pk, size_t size);
bool loadPrivateKey(Stream& stream, size_t size);
bool loadPrivateKey(const uint8_t* pk, size_t size);
bool loadCACert(Stream& stream, size_t size);
bool loadCACert(const uint8_t* pk, size_t size);

template<typename TFile>
bool loadCertificate(TFile& file) {
Expand Down