Skip to content
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

Allow usage of byte arrays to set RootCAs #2968

Merged
merged 2 commits into from
Feb 15, 2017
Merged
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
20 changes: 14 additions & 6 deletions libraries/ESP8266WiFi/src/WiFiClientSecure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,20 +547,28 @@ bool WiFiClientSecure::verifyCertChain(const char* domain_name)
return _verifyDN(domain_name);
}

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

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

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

bool WiFiClientSecure::loadCACert(Stream& stream, size_t size)
Expand Down
7 changes: 4 additions & 3 deletions libraries/ESP8266WiFi/src/WiFiClientSecure.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ class WiFiClientSecure : public WiFiClient {
size_t peekBytes(uint8_t *buffer, size_t length) override;
void stop() override;

void setCertificate(const uint8_t* cert_data, size_t size);
void setPrivateKey(const uint8_t* pk, size_t size);
bool setCACert(const uint8_t* pk, size_t size);
bool setCertificate(const uint8_t* pk, size_t size);
bool setPrivateKey(const uint8_t* pk, size_t size);

bool loadCACert(Stream& stream, size_t size);
bool loadCertificate(Stream& stream, size_t size);
bool loadPrivateKey(Stream& stream, size_t size);
bool loadCACert(Stream& stream, size_t size);

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