Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: espressif/arduino-esp32
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: sguarin/arduino-esp32
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fix_streamLoad
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 27, 2021

  1. Temporary fix

    sguarin committed Nov 27, 2021
    1
    Copy the full SHA
    3b31484 View commit details
  2. Copy the full SHA
    dee2f0e View commit details

Commits on Dec 25, 2021

  1. Copy the full SHA
    1e962d3 View commit details
Showing with 22 additions and 1 deletion.
  1. +20 −1 libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
  2. +2 −0 libraries/WiFiClientSecure/src/WiFiClientSecure.h
21 changes: 20 additions & 1 deletion libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
Original file line number Diff line number Diff line change
@@ -261,21 +261,25 @@ void WiFiClientSecure::setInsecure()
void WiFiClientSecure::setCACert (const char *rootCA)
{
_CA_cert = rootCA;
_use_insecure = false;
}

void WiFiClientSecure::setCertificate (const char *client_ca)
{
_cert = client_ca;
_use_insecure = false;
}

void WiFiClientSecure::setPrivateKey (const char *private_key)
{
_private_key = private_key;
_use_insecure = false;
}

void WiFiClientSecure::setPreSharedKey(const char *pskIdent, const char *psKey) {
_pskIdent = pskIdent;
_psKey = psKey;
_use_insecure = false;
}

bool WiFiClientSecure::verify(const char* fp, const char* domain_name)
@@ -300,8 +304,23 @@ char *WiFiClientSecure::_streamLoad(Stream& stream, size_t size) {
return dest;
}

bool WiFiClientSecure::_streamLoad(char **destPtr, Stream& stream, size_t size) {
*destPtr = (char*)realloc(*destPtr, size+1);
if (!*destPtr) {
return false;
}
if (size != stream.readBytes(*destPtr, size)) {
free(*destPtr);
*destPtr = nullptr;
return false;
}
(*destPtr)[size] = '\0';
return true;
}

bool WiFiClientSecure::loadCACert(Stream& stream, size_t size) {
char *dest = _streamLoad(stream, size);
char *dest = _CA_cert;
_streamLoad(&dest, stream, size);
bool ret = false;
if (dest) {
setCACert(dest);
2 changes: 2 additions & 0 deletions libraries/WiFiClientSecure/src/WiFiClientSecure.h
Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ class WiFiClientSecure : public WiFiClient
void setAlpnProtocols(const char **alpn_protos);
const mbedtls_x509_crt* getPeerCertificate() { return mbedtls_ssl_get_peer_cert(&sslclient->ssl_ctx); };
bool getFingerprintSHA256(uint8_t sha256_result[32]) { return get_peer_fingerprint(sslclient, sha256_result); };

int setTimeout(uint32_t seconds){ return 0; }

operator bool()
@@ -105,6 +106,7 @@ class WiFiClientSecure : public WiFiClient

private:
char *_streamLoad(Stream& stream, size_t size);
bool _streamLoad(char **destPtr, Stream& stream, size_t size);

//friend class WiFiServer;
using Print::write;