Skip to content

Commit 39aa8d9

Browse files
PR #492: Fix certificate paths and add build instructions
- Use CMake to configure certificate paths - Add wolfSSL and wolfMQTT build instructions - Add debug prints for certificate loading - Update documentation Co-Authored-By: [email protected] <[email protected]>
1 parent 755109b commit 39aa8d9

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

fullstack/freertos-wolfip-wolfmqtt/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ project(freertos_wolfssl_demo C)
55
set(CMAKE_C_STANDARD 11)
66
set(CMAKE_C_STANDARD_REQUIRED ON)
77

8-
# wolfSSL configuration
9-
add_definitions(-DWOLFSSL_USER_SETTINGS)
8+
# Configure certificate paths
9+
set(WOLFSSL_CERTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../wolfssl/certs")
10+
add_definitions(
11+
-DWOLFSSL_USER_SETTINGS
12+
-DMQTT_TLS_CA_CERT="${WOLFSSL_CERTS_DIR}/ca-cert.pem"
13+
-DMQTT_TLS_CLIENT_CERT="${WOLFSSL_CERTS_DIR}/client-cert.pem"
14+
-DMQTT_TLS_CLIENT_KEY="${WOLFSSL_CERTS_DIR}/client-key.pem"
15+
)
1016

1117
# FreeRTOS Kernel source files for POSIX port
1218
set(FREERTOS_PORT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/freertos/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix)

fullstack/freertos-wolfip-wolfmqtt/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ This example demonstrates a full-stack embedded MQTT client using FreeRTOS, wolf
1616
- Mosquitto broker (for testing)
1717
- wolfSSL libraries
1818

19+
## Building Dependencies
20+
21+
### wolfSSL
22+
```bash
23+
cd ~/repos/wolfssl
24+
./autogen.sh
25+
./configure --enable-tls13 --enable-aead --enable-hkdf \
26+
--enable-certgen --enable-certreq --enable-certext \
27+
--enable-tlsx --enable-snl --enable-ocsp \
28+
--enable-cryptocb --enable-des3 --enable-curve25519 \
29+
--enable-ed25519 --enable-keygen --enable-rsapss \
30+
--enable-sha224 --enable-sha384 --enable-sha512 \
31+
--enable-dh --enable-opensslextra
32+
make
33+
sudo make install
34+
```
35+
36+
### wolfMQTT
37+
```bash
38+
cd ~/repos/wolfMQTT
39+
./autogen.sh
40+
./configure --enable-tls --enable-nonblock
41+
make
42+
sudo make install
43+
```
44+
1945
## Building and Running
2046

2147
### Setup

fullstack/freertos-wolfip-wolfmqtt/include/user_settings.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
#define ECC_TIMING_RESISTANT
3232
#define WC_TIMING_RESISTANT
3333

34-
/* TLS Certificate Paths */
35-
#define MQTT_TLS_CA_CERT "../../../wolfssl/certs/ca-cert.pem"
36-
#define MQTT_TLS_CLIENT_CERT "../../../wolfssl/certs/client-cert.pem"
37-
#define MQTT_TLS_CLIENT_KEY "../../../wolfssl/certs/client-key.pem"
38-
3934
/* wolfSSL TLS configuration */
4035
#define WOLFSSL_TLS13
4136
#define WOLFSSL_TLS13_NO_OLD_TLS

fullstack/freertos-wolfip-wolfmqtt/src/mqtt_net.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ static int mqtt_tls_init(void) {
3939
return -1;
4040
}
4141

42+
printf("Loading CA certificate from: %s\n", MQTT_TLS_CA_CERT);
4243
if (wolfSSL_CTX_load_verify_locations(mqtt_tls_ctx, MQTT_TLS_CA_CERT, NULL) != SSL_SUCCESS) {
4344
printf("Failed to load CA certificate\n");
4445
return -1;
4546
}
47+
48+
printf("Loading client certificate from: %s\n", MQTT_TLS_CLIENT_CERT);
4649
if (wolfSSL_CTX_use_certificate_file(mqtt_tls_ctx, MQTT_TLS_CLIENT_CERT, SSL_FILETYPE_PEM) != SSL_SUCCESS) {
4750
printf("Failed to load client certificate\n");
4851
return -1;
4952
}
53+
54+
printf("Loading client key from: %s\n", MQTT_TLS_CLIENT_KEY);
5055
if (wolfSSL_CTX_use_PrivateKey_file(mqtt_tls_ctx, MQTT_TLS_CLIENT_KEY, SSL_FILETYPE_PEM) != SSL_SUCCESS) {
5156
printf("Failed to load client key\n");
5257
return -1;

0 commit comments

Comments
 (0)