-
Notifications
You must be signed in to change notification settings - Fork 110
Supported alternative TLS library. #673
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
Conversation
This is currently just PoC. |
93c6e0b
to
1b33ca5
Compare
2301e16
to
c87dc47
Compare
Codecov Report
@@ Coverage Diff @@
## master #673 +/- ##
=======================================
Coverage 82.06% 82.06%
=======================================
Files 47 47
Lines 7082 7082
=======================================
Hits 5812 5812
Misses 1270 1270 |
Using alternative TLS librarymqtt_cpp uses OpenSSL by default. User can use alternative TLS library such as GNUTLS instead of OpenSSL. How to useDefine the following three preprosessor macros.
If you define the macros, then the default value is overridden. Note that MQTT_TLS_WS_INCLUDE is required only if MQTT_USE_TLS is defined. Design choicemqtt_cpp doesn't care about alternative TLS libraries directly. In other words, it is out of scope. mqtt_cpp provides minimal support for the alternative TLS libraries. |
This doesn't work with GnuTLS. We'd need for this to be pulled out into a function in tls.hpp This is what I'd done in my PR earlier: inline constexpr bool is_tls_short_read(int error_val) #if MQTT_USE_TLS == MQTT_TLS_OPENSSL
} Refers to: include/mqtt/endpoint.hpp:4569 in c87dc47. [](commit_id = c87dc47, deletion_comment = False) |
I'm not sure how to do that. But could you write a PR to fix the issue ? The target PR is #673 (add_alt_tls_support branch) #if !defined(MQTT_TLS_INCLUDE)
#define MQTT_TLS_INCLUDE <boost/asio/ssl.hpp>
#endif // !defined(MQTT_TLS_INCLUDE) By default, OpenSSL is used. If you override some macro (maybe you newly introduce), then GnuTLS tls short read is enabled. |
fbb5104
to
3af7fa0
Compare
Just add the macro MQTT_TLS_ERROR_COMPARISON. You can customize it using
|
@redboltz Yep, that worked. Thanks! There's one other thing though. In the CMakeLists.txt at the root and the CMakeLists.txt under include/, we are finding the OpenSSL library if MQTT_USE_TLS is set and linking to it. Would it be possible to disable that? In order to use these changes, I had to add a find_package(OpenSSL) to my project's CMakeLists.txt |
I think that you can do as follows: cmake -DMQTT_USE_TLS=OFF -DCMAKE_CXX_FLAGS="-DMQTT_USE_TLS -DMQTT_TLS_INCLUDE=...." .. You can omit |
@redboltz Ah cool, I'll try that. Thanks! I'll let you know soon if everything works as expected |
3af7fa0
to
63d1c20
Compare
Due to #718 fix, MQTT_TLS_ERROR_COMPARISON is no longer required. |
Added customization point for GNUTls.
63d1c20
to
3a222bb
Compare
@redboltz Sorry for getting back so late. Finally got to this again. So, I ran the cmake command based on your recommendation:
However, when I try to build an executable that depends on the mqtt_cpp library, I get some errors:
Everything works fine if I set the MQTT_USE_TLS flag to 'ON' in the Cmake options as well. |
If you defined MQTT_USE_TLS correctly, make_tls_sync_client should be defined. See the following code: It seems that you need to check actual compiler options using VERBOSE=1, and preprosessor output. |
@redboltz Yep, my bad. It worked. Thanks for the help! Will you be merging this change with master now? Also, any plans of an upcoming release that might include this change? Thanks! |
merged. Release is not decided yet. |
No description provided.