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)
- upload in https using examplefile-upload-html-form is always pending in chrome but is ok in firefox. HOT 1
- Socket error after ota-updating the filesystem image HOT 1
- Fix for #2619 breaks fix for #2603 HOT 3
- Cleanup string API HOT 5
- mongoose.c:7543:accept_conn 1 accept failed, errno 24 HOT 1
- mg_http_next_multipart bug HOT 3
- cannot connect MQTT to STM32F407 HOT 1
- When I used the TLS scanning tool (https://github.com/rbsec/sslscan, scanning command: sslscan --tlsall 127.0.0.1:8443) to scan the 8443 port of the mongoose examples http-restful-server, the program appeared Infinite loop, continuous log printing, even if I have ended the TLS scan command. HOT 2
- The "mg_url_host" function is not work? HOT 1
- Can FreeRTOS_IPInit_Multi function be used properly? HOT 3
- Wrong assets in 7.14 HOT 1
- Mongoose accepts HTTP requests with invalid versions
- Mongoose accepts requests containing multiple differing Content-Length headers.
- Mongoose ignores `Connection: close` headers
- Potential Memory Leak in `mg_timer_free` Function HOT 6
- [RST, ACK] frame when starting downloading file HOT 1
- Issue with `mg_snprintf` Not Supporting `%zu` Format Specifier HOT 2
- Mongoose using OpenSSL memory leak HOT 4
- Unclear how to send mg_wakeup from a thread that is not associated with a specific connection. HOT 10
- New chacha20 is causing nightly test failures due to conversion warnings
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.