Skip to content

Commit 05b7a69

Browse files
committed
remove from logsthe secrets of network settings
1 parent ccab1b6 commit 05b7a69

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/ANetworkConfigurator_Config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,7 @@
126126
#ifndef BCP_DEBUG_PACKET
127127
#define BCP_DEBUG_PACKET 0
128128
#endif
129+
130+
// Set to 1 for logging newtwork configurations secrets
131+
// Be careful the secrets will be printed in the serial monitor in clear text
132+
#define DEBUG_NETWORK_CREDENTIALS 0

src/NetworkConfigurator.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,10 @@ void NetworkConfiguratorClass::printNetworkSettings() {
598598
#if defined(BOARD_HAS_WIFI)
599599
case NetworkAdapter::WIFI:
600600
DEBUG_INFO("WIFI");
601-
DEBUG_INFO("SSID: %s PSW: %s", _networkSetting.wifi.ssid, _networkSetting.wifi.pwd);//TODO remove psw
601+
DEBUG_INFO("SSID: %s", _networkSetting.wifi.ssid);
602+
#if DEBUG_NETWORK_CREDENTIALS
603+
DEBUG_INFO("PSW: %s", _networkSetting.wifi.ssid, _networkSetting.wifi.pwd);
604+
#endif
602605
break;
603606
#endif
604607

@@ -620,49 +623,59 @@ void NetworkConfiguratorClass::printNetworkSettings() {
620623
#if defined(BOARD_HAS_NB)
621624
case NetworkAdapter::NB:
622625
DEBUG_INFO("NB-IoT");
623-
DEBUG_INFO("PIN: %s", _networkSetting.nb.pin);
624626
DEBUG_INFO("APN: %s", _networkSetting.nb.apn);
625627
DEBUG_INFO("Login: %s", _networkSetting.nb.login);
628+
#if DEBUG_NETWORK_CREDENTIALS
629+
DEBUG_INFO("PIN: %s", _networkSetting.nb.pin);
626630
DEBUG_INFO("Pass: %s", _networkSetting.nb.pass);
631+
#endif
627632
break;
628633
#endif
629634

630635
#if defined(BOARD_HAS_GSM)
631636
case NetworkAdapter::GSM:
632637
DEBUG_INFO("GSM");
633-
DEBUG_INFO("PIN: %s", _networkSetting.gsm.pin);
634638
DEBUG_INFO("APN: %s", _networkSetting.gsm.apn);
635639
DEBUG_INFO("Login: %s", _networkSetting.gsm.login);
640+
#if DEBUG_NETWORK_CREDENTIALS
641+
DEBUG_INFO("PIN: %s", _networkSetting.gsm.pin);
636642
DEBUG_INFO("Pass: %s", _networkSetting.gsm.pass);
643+
#endif
637644
break;
638645
#endif
639646

640647
#if defined(BOARD_HAS_CATM1_NBIOT)
641648
case NetworkAdapter::CATM1:
642649
DEBUG_INFO("CATM1");
643-
DEBUG_INFO("PIN: %s", _networkSetting.catm1.pin);
644650
DEBUG_INFO("APN: %s", _networkSetting.catm1.apn);
645651
DEBUG_INFO("Login: %s", _networkSetting.catm1.login);
652+
#if DEBUG_NETWORK_CREDENTIALS
653+
DEBUG_INFO("PIN: %s", _networkSetting.catm1.pin);
646654
DEBUG_INFO("Pass: %s", _networkSetting.catm1.pass);
655+
#endif
647656
DEBUG_INFO("Band: %d", _networkSetting.catm1.band);
648657
break;
649658
#endif
650659

651660
#if defined(BOARD_HAS_CELLULAR)
652661
case NetworkAdapter::CELL:
653662
DEBUG_INFO("CELLULAR");
654-
DEBUG_INFO("PIN: %s", _networkSetting.cell.pin);
655663
DEBUG_INFO("APN: %s", _networkSetting.cell.apn);
656664
DEBUG_INFO("Login: %s", _networkSetting.cell.login);
665+
#if DEBUG_NETWORK_CREDENTIALS
666+
DEBUG_INFO("PIN: %s", _networkSetting.cell.pin);
657667
DEBUG_INFO("Pass: %s", _networkSetting.cell.pass);
668+
#endif
658669
break;
659670
#endif
660671

661672
#if defined(BOARD_HAS_LORA)
662673
case NetworkAdapter::LORA:
663674
DEBUG_INFO("LORA");
664675
DEBUG_INFO("AppEUI: %s", _networkSetting.lora.appeui);
676+
#if DEBUG_NETWORK_CREDENTIALS
665677
DEBUG_INFO("AppKey: %s", _networkSetting.lora.appkey);
678+
#endif
666679
DEBUG_INFO("Band: %d", _networkSetting.lora.band);
667680
DEBUG_INFO("Channel mask: %s", _networkSetting.lora.channelMask);
668681
DEBUG_INFO("Device class: %c", _networkSetting.lora.deviceClass);

0 commit comments

Comments
 (0)