Skip to content

Commit

Permalink
Fix ESP32 log issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Dec 24, 2022
1 parent 2d00cef commit 62a4fe2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ESP_SSLClient",
"version": "1.0.4",
"version": "1.0.5",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "The upgradable SSL Client for ESP8266 and ESP32 that supports many network interfaces e.g., WiFiClient, EthernetClient, GSMClient.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=ESP_SSLClient

version=1.0.4
version=1.0.5

author=Mobizt

Expand Down
26 changes: 13 additions & 13 deletions src/esp32/MB_ESP32_SSL_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char

ssl_client_print(mb_ssl_client_str_2);

log_v(mb_ssl_client_str_2 /* "Seeding the random number generator" */);
log_v("Seeding the random number generator");
mbedtls_entropy_init(&ssl->entropy_ctx);

ret = mbedtls_ctr_drbg_seed(&ssl->drbg_ctx, mbedtls_entropy_func, &ssl->entropy_ctx, (const unsigned char *)custom_str, strlen(custom_str));
Expand All @@ -195,7 +195,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char

ssl_client_print(mb_ssl_client_str_3);

log_v(mb_ssl_client_str_3 /* "Setting up the SSL/TLS structure..." */);
log_v("Setting up the SSL/TLS structure...");

if ((ret = mbedtls_ssl_config_defaults(&ssl->ssl_conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT)) != 0)
{
Expand All @@ -211,12 +211,12 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char
ssl_client_print(mb_ssl_client_str_15);

mbedtls_ssl_conf_authmode(&ssl->ssl_conf, MBEDTLS_SSL_VERIFY_NONE);
log_i(mb_ssl_client_str_15 /* "WARNING: Skipping SSL Verification. INSECURE!" */);
log_i("WARNING: Skipping SSL Verification. INSECURE!");
}
else if (rootCABuff != NULL)
{
ssl_client_print(mb_ssl_client_str_4);
log_v(mb_ssl_client_str_4 /* "Loading CA cert" */);
log_v("Loading CA cert");

mbedtls_x509_crt_init(&ssl->ca_cert);
mbedtls_ssl_conf_authmode(&ssl->ssl_conf, MBEDTLS_SSL_VERIFY_REQUIRED);
Expand All @@ -234,7 +234,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char
else if (pskIdent != NULL && psKey != NULL)
{
ssl_client_print(mb_ssl_client_str_5);
log_v(mb_ssl_client_str_5 /* "Setting up PSK" */);
log_v("Setting up PSK");
// convert PSK from hex to binary
if ((strlen(psKey) & 1) != 0 || strlen(psKey) > 2 * MBEDTLS_PSK_MAX_LEN)
{
Expand Down Expand Up @@ -296,7 +296,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char

ssl_client_print(mb_ssl_client_str_8);

log_v(mb_ssl_client_str_8 /* "Loading CRT cert" */);
log_v("Loading CRT cert");

ret = mbedtls_x509_crt_parse(&ssl->client_cert, (const unsigned char *)cli_cert, strlen(cli_cert) + 1);
if (ret < 0)
Expand All @@ -309,7 +309,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char

ssl_client_print(mb_ssl_client_str_9);

log_v(mb_ssl_client_str_9 /* "Loading private key" */);
log_v("Loading private key");
ret = mbedtls_pk_parse_key(&ssl->client_key, (const unsigned char *)cli_key, strlen(cli_key) + 1, NULL, 0);

if (ret != 0)
Expand All @@ -323,7 +323,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char

ssl_client_print(mb_ssl_client_str_10);

log_v(mb_ssl_client_str_10 /* "Setting hostname for TLS session..." */);
log_v("Setting hostname for TLS session...");

// Hostname set here should match CN in server certificate
if ((ret = mbedtls_ssl_set_hostname(&ssl->ssl_ctx, host)) != 0)
Expand All @@ -344,7 +344,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char

ssl_client_print(mb_ssl_client_str_11);

log_v(mb_ssl_client_str_11 /* "Performing the SSL/TLS handshake..." */);
log_v("Performing the SSL/TLS handshake...");
unsigned long handshake_start_time = millis();
while ((ret = mbedtls_ssl_handshake(&ssl->ssl_ctx)) != 0)
{
Expand Down Expand Up @@ -373,7 +373,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char
}
ssl_client_print(mb_ssl_client_str_12);

log_v(mb_ssl_client_str_12 /* "Verifying peer X.509 certificate..." */);
log_v("Verifying peer X.509 certificate...");

if ((flags = mbedtls_ssl_get_verify_result(&ssl->ssl_ctx)) != 0)
{
Expand All @@ -385,7 +385,7 @@ int MB_ESP32_SSL_Client::connect_ssl(ssl_ctx *ssl, const char *host, const char
}
else
{
log_v(F("Certificate verified."));
log_v("Certificate verified.");
}

if (rootCABuff != NULL)
Expand Down Expand Up @@ -551,7 +551,7 @@ bool MB_ESP32_SSL_Client::verify_ssl_fingerprint(ssl_ctx *ssl, const char *fp, c

if (!crt)
{
log_d(F("could not fetch peer certificate"));
log_d("could not fetch peer certificate");
return false;
}

Expand All @@ -566,7 +566,7 @@ bool MB_ESP32_SSL_Client::verify_ssl_fingerprint(ssl_ctx *ssl, const char *fp, c
// Check if fingerprints match
if (memcmp(fingerprint_local, fingerprint_remote, 32))
{
log_d(F("fingerprint doesn't match"));
log_d("fingerprint doesn't match");
return false;
}

Expand Down

0 comments on commit 62a4fe2

Please sign in to comment.