-
-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling MbedTLS #179
Comments
Here are a couple of documentation links with details on how a specific configuration can be created to minimize the binary size and memory usage: |
I'm willing to merge changes that help get you unblocked and able to use mbed-tls with redbean. As for merging it into the mainline distribution, I'm reluctant to do that. It's not just a question of code size. It's a question of the responsibilities offering security technologies entails. redbean lets you use something like stunnel to bolt on the tls security layer separately. The varnish proxy does the same thing. I seem to recall the "unsecure approach" (neither secure or insecure) even being required by certain FIPS standards. So I believe it should be possible for you to choose whatever security approach works best for you. It's just not something I can recommend people do or not do more broadly. |
@jart, thank you for looking into this. What would merging the changes entail? Would it add TSL support, but keep it behind an option that is off by default or would it make it available as a third-party module or something else? Maybe you can allow hooking into Another option would be to integrate mbedtsl as the library and use its encryption/decryption module to sign/encrypt/decrypt individual messages. |
@jart, what would be the best way to see if MbedTLS can be integrated? Would it make sense to expose Lua methods for establishing connections and reading/writing messages (similar to how onHttpRequest is implemented), so I can use the Lua messages to establish handshake and provide read/write functions? This appears to be the least invasive method and would potentially allow other TLS implementations (and also would keep things optional and out of the core). |
I'm sorry MbedTLS integration is not a contribution that can be accepted at this time. I believe it should be possible for you to satisfy your requirements by implementing SSL at the frontend, or by using a separate program such as stunnel. redbean is designed to play a part in the broader systems architecture of your choosing. There currently isn't an intent to provide those architectural choices within redbean itself. |
The situation changed and it turns out we can do this after all. You'll be excited to hear that redbean now has mbedtls support as of cc19207 Enjoy! |
Super exciting; thank you for incorporating this! |
I've looked into available TLS implementations and it appears MbedTLS may be the best one to integrate with Cosmopolitan/Redbean, as it's described as "easy to understand, use, integrate and expand" and "Its small code footprint makes it suitable for embedded systems". It's available under Apache-2.0 license.
Here is the list of changes I applied to compile it using Cosmopolitan libraries:
netinet/in.h
andnetdb.h
.sockaddr_in6
definitions based onws2ipdef.h
andin6addr.h
from mingw distribution:I can write a script that would apply these changes to the original MbedTLS source tree (to minimize the amount of manual work to be done for upgrades), but not sure what tools I can expect. Is
sed
orlua
interpreter available in addition to shell to execute the scripts?What would be needed to integrate MbedTLS into Redbean? I realize that the size is critical (as discussed in #95) and MbedTLS seems to work quite well in that regard: its libraries are around 900k and the compiled binary is likely to be much less, as most of the code is not going to be needed for adding TLS support.
The text was updated successfully, but these errors were encountered: