Skip to content

Commit 7dba257

Browse files
committed
Peer review fixes and demo fixes.
1 parent f301301 commit 7dba257

7 files changed

Lines changed: 26 additions & 21 deletions

File tree

.github/workflows/stm32h563-m33mu.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ jobs:
120120
steps:
121121
- uses: actions/checkout@v4
122122

123-
- name: Clone wolfSSL, wolfSSH, wolfMQTT
123+
- name: Clone wolfSSL, wolfSSH, wolfMQTT (pinned to stable tags)
124124
run: |
125125
set -euo pipefail
126126
cd ..
127-
git clone --depth 1 https://github.com/wolfSSL/wolfssl.git
128-
git clone --depth 1 https://github.com/wolfSSL/wolfssh.git
129-
git clone --depth 1 https://github.com/wolfSSL/wolfMQTT.git wolfmqtt
127+
git clone --depth 1 --branch v5.8.4-stable https://github.com/wolfSSL/wolfssl.git
128+
git clone --depth 1 --branch v1.4.22-stable https://github.com/wolfSSL/wolfssh.git
129+
git clone --depth 1 --branch v1.21.0 https://github.com/wolfSSL/wolfMQTT.git wolfmqtt
130130
131131
- name: Install host tools
132132
run: |

src/port/stm32h563/demo.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# board-ip defaults to 192.168.12.11
1010
#
1111

12-
BOARD_IP="${1:-1192.168.12.11}"
12+
BOARD_IP="${1:-192.168.12.11}"
1313

1414
# Colors
1515
BLD='\033[1m'
@@ -115,15 +115,17 @@ pause
115115
# ---------------------------------------------------------------------------
116116
banner "3. HTTPS Web Server (Port 443) - TLS 1.3"
117117

118-
step "Fetch the status page with curl"
119-
run_cmd "curl -s -k https://${BOARD_IP}/ | sed 's/<[^>]*>//g; s/^[[:space:]]*//; /^$/d'"
120-
118+
step "Fetch the status page and inspect TLS 1.3 handshake"
119+
cmd_show "curl -vsk https://${BOARD_IP}/ 2>&1"
121120
echo ""
122-
step "Inspect the TLS 1.3 handshake"
123-
cmd_show "echo | openssl s_client -connect ${BOARD_IP}:443 -tls1_3 -brief 2>&1"
121+
# Single connection: extract TLS info from stderr, page from stdout
122+
CURL_OUT=$(curl -vsk "https://${BOARD_IP}/" 2>&1)
123+
# Show TLS handshake details
124+
echo "$CURL_OUT" | grep -E '^\*\s*(SSL|TLS|subject|issuer|expire|server certificate)' | sed 's/^/ /'
124125
echo ""
125-
echo | openssl s_client -connect "${BOARD_IP}":443 -tls1_3 -brief 2>&1 | \
126-
grep -E '(Protocol|Ciphersuite|Peer certificate|Server certificate|subject|issuer|Verification)' | \
126+
# Show page content (strip HTML tags, add newlines between table cells)
127+
echo "$CURL_OUT" | grep -v '^\*\s' | grep -v '^[<>{}]' | \
128+
sed 's/<\/\(tr\|h1\|title\)>/\n/g; s/<[^>]*>//g; s/^[[:space:]]*//; /^$/d' | \
127129
sed 's/^/ /'
128130
echo ""
129131

src/port/stm32h563/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,15 @@ static void uart_puts(const char *s)
331331
* Uses vsnprintf from newlib-nano + uart_puts. */
332332
void wolfmqtt_log(const char *fmt, ...)
333333
{
334-
char buf[128];
334+
char buf[256];
335335
va_list ap;
336+
int n;
336337
va_start(ap, fmt);
337-
vsnprintf(buf, sizeof(buf), fmt, ap);
338+
n = vsnprintf(buf, sizeof(buf), fmt, ap);
338339
va_end(ap);
339340
uart_puts(buf);
341+
if (n >= (int)sizeof(buf))
342+
uart_puts("...[truncated]\n");
340343
}
341344

342345
static void uart_puthex(uint32_t val)

src/port/stm32h563/mqtt_broker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int broker_tls_init(void)
108108
/* Load server certificate from embedded PEM */
109109
if (wolfSSL_CTX_use_certificate_buffer(ctx.ssl_ctx,
110110
(const unsigned char *)server_cert_pem,
111-
(long)server_cert_pem_len,
111+
(long)strlen(server_cert_pem),
112112
WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) {
113113
debug_print("MQTT Broker: Load cert failed\n");
114114
wolfSSL_CTX_free(ctx.ssl_ctx);
@@ -119,7 +119,7 @@ static int broker_tls_init(void)
119119
/* Load server private key from embedded PEM */
120120
if (wolfSSL_CTX_use_PrivateKey_buffer(ctx.ssl_ctx,
121121
(const unsigned char *)server_key_pem,
122-
(long)server_key_pem_len,
122+
(long)strlen(server_key_pem),
123123
WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) {
124124
debug_print("MQTT Broker: Load key failed\n");
125125
wolfSSL_CTX_free(ctx.ssl_ctx);

src/port/stm32h563/tls_server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int tls_server_init(struct wolfIP *stack, uint16_t port,
139139
debug_print("TLS: Loading certificate\n");
140140
ret = wolfSSL_CTX_use_certificate_buffer(server.ctx,
141141
(const unsigned char *)server_cert_pem,
142-
server_cert_pem_len - 1, /* exclude null terminator */
142+
(long)strlen(server_cert_pem),
143143
WOLFSSL_FILETYPE_PEM);
144144
if (ret != WOLFSSL_SUCCESS) {
145145
debug_print("TLS: Failed to load certificate\n");
@@ -152,7 +152,7 @@ int tls_server_init(struct wolfIP *stack, uint16_t port,
152152
debug_print("TLS: Loading private key\n");
153153
ret = wolfSSL_CTX_use_PrivateKey_buffer(server.ctx,
154154
(const unsigned char *)server_key_pem,
155-
server_key_pem_len - 1, /* exclude null terminator */
155+
(long)strlen(server_key_pem),
156156
WOLFSSL_FILETYPE_PEM);
157157
if (ret != WOLFSSL_SUCCESS) {
158158
debug_print("TLS: Failed to load private key\n");

src/port/stm32h563/user_settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ int custom_rand_gen_block(unsigned char* output, unsigned int sz);
244244
* wolfmqtt_log() is implemented in main.c using vsnprintf + uart_puts. */
245245
#define WOLFMQTT_CUSTOM_PRINTF
246246
extern void wolfmqtt_log(const char *fmt, ...);
247-
#define PRINTF(_f_, ...) wolfmqtt_log(_f_ "\n", ##__VA_ARGS__)
247+
#define PRINTF(_f_, ...) wolfmqtt_log(_f_, ##__VA_ARGS__)
248248

249249
/* Disable error strings to save space */
250250
#define WOLFMQTT_NO_ERROR_STRINGS

src/port/stm32h753/mqtt_broker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int broker_tls_init(void)
108108
/* Load server certificate from embedded PEM */
109109
if (wolfSSL_CTX_use_certificate_buffer(ctx.ssl_ctx,
110110
(const unsigned char *)server_cert_pem,
111-
(long)server_cert_pem_len,
111+
(long)strlen(server_cert_pem),
112112
WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) {
113113
debug_print("MQTT Broker: Load cert failed\n");
114114
wolfSSL_CTX_free(ctx.ssl_ctx);
@@ -119,7 +119,7 @@ static int broker_tls_init(void)
119119
/* Load server private key from embedded PEM */
120120
if (wolfSSL_CTX_use_PrivateKey_buffer(ctx.ssl_ctx,
121121
(const unsigned char *)server_key_pem,
122-
(long)server_key_pem_len,
122+
(long)strlen(server_key_pem),
123123
WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) {
124124
debug_print("MQTT Broker: Load key failed\n");
125125
wolfSSL_CTX_free(ctx.ssl_ctx);

0 commit comments

Comments
 (0)