Comments (2)
Thank you for your opinions. I beg to differ.
The very same section you mention, in the following paragraphs, shows other two forms in which you can load your credentials.
They can also be loaded from a file in an embedded filesystem, using mg_unpacked() as shown above:
struct mg_tls_opts opts = {.ca = mg_unpacked("/certs/ca.pem")};
This accesses the file directly from the code, where it has been embedded.
"above" in the first sentence, makes reference to what you've seen in the server and client sections.
Finally, certificates and keys can be defined as C strings in source code:
That can be seen in the http-restful-server example, linked in the server section, the device-dashboard example, and probably others too.
These three ways are also tested every day on every push:
Lines 1286 to 1289 in dd64582
Lines 786 to 787 in dd64582
Lines 790 to 794 in dd64582
Which way you choose, is up to you.
Mongoose is embedded oriented, and while we serve the OS world, we aim to support devices with no built-in filesystem.
The client and server sections do not say "do this to load your credentials", those sections are explaining that you have to initalize TLS at that point, and how real world examples taken from actual examples in our repo, linked in the final lines of that section, do it:
TCP server:
Lines 60 to 63 in dd64582
HTTP client:
mongoose/examples/http-client/main.c
Lines 31 to 34 in dd64582
Both show you how to build the embedded file system, and the TCP server example does not carry the packed filesystem itself so it will generate it on the fly for you. It also shows both client and server.
[tcp]$ make CFLAGS_EXTRA="-DMG_TLS=MG_TLS_OPENSSL -lssl -lcrypto"
cc ../../test/pack.c -o ./pack
./pack certs/ss_server.pem certs/ss_ca.pem certs/ss_client.pem > packed_fs.c
cc main.c mongoose.c packed_fs.c -W -Wall -Wextra -g -I. -DMG_ENABLE_PACKED_FS=1 -DMG_TLS=MG_TLS_OPENSSL -lssl -lcrypto -o example
./example
21064ce 2 main.c:56:sfn SERVER is listening
2106532 2 main.c:19:cfn CLIENT has been initialized
2106532 2 main.c:83:timer_fn CLIENT connecting
2106532 2 main.c:21:cfn CLIENT connected
2106532 2 main.c:58:sfn SERVER accepted a connection
21078c3 2 main.c:43:cfn CLIENT sent data
21078c3 2 main.c:67:sfn SERVER got data: Hi, there
21078c3 2 main.c:31:cfn CLIENT got data: Hi, there
2108ac3 2 main.c:34:cfn CLIENT disconnected
2108ac3 2 main.c:71:sfn SERVER disconnected
from mongoose.
I'm sorry. I did not specify MG_ENABLE_PACKED_FS when compiling. I think that's what caused mg_unpacked(path) to not work for me. My bad.
from mongoose.
Related Issues (20)
- Chunked message body incorrectly terminated on `\r\n\r\n` instead of `0\r\n\r\n`
- About running on a riscv-linux HOT 1
- MG_EV_CLOSE is fired before MG_EV_HTTP_MSG HOT 16
- RP2040 W5500 and DHCP HOT 14
- POST and TLS client HOT 11
- gcc warning in builtin TLS code HOT 2
- Unbounded growth in transmit buffer with WebSockets HOT 8
- Bus error crash in the new mg_wakeup() function HOT 4
- how to config in mbed ?
- Prefix PHY_* constants in STM32 drivers with MG_ to avoid name conflicts
- Rename MG_ENABLE_FILE to MG_ENABLE_POSIX_FS
- MG_ARCH_FREERTOS_LWIP is not available in Mongoose 7.12 HOT 1
- Mongoose prematurely closes connections when the second request in a pipeline is invalid
- Mongoose closes the connection without responding to POST requests that don't have explicit lengths HOT 2
- Discrepancy Between Mongoose Versions on Espressif Component Registry and Official Release HOT 1
- The maximum DNS response count should be a larger value HOT 1
- Mbedtls error and memory leak when connecting through WebSocket HOT 1
- Reading post data from https connection fails now and then HOT 24
- bind define conflict between "lwip/sockets.h" and c++ <functional> HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose.