wolfSSL / wolfMQTT

wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
https://www.wolfssl.com
GNU General Public License v2.0
518 stars 156 forks source link

HAVE_SNI define in wolfssl #306

Closed afridali123 closed 2 years ago

afridali123 commented 2 years ago

hi,

i m running example of ./mqttclient -S "host"

i went through code and found if we define HAVE_SNI then it will take mqttCtx.host as tls host. can you please help me in where i can define HAVE_SNI , can i define in mqttclient.h file ??

embhorn commented 2 years ago

Hello @afridali123

The HAVE_SNI option should be defined in wolfSSL, using ./configure --enable-sni (or HAVE_SNI in the user_settings.h header).

afridali123 commented 2 years ago

can you guide me where this user_settings.h ??

embhorn commented 2 years ago

How are you building the library wolfSSL?

afridali123 commented 2 years ago

i m just using steps guide in github through make running mqttclient example

embhorn commented 2 years ago

Okay, great. The TLS features of wolfMQTT require wolfSSL https://github.com/wolfSSL/wolfssl

When you build wolfSSL:

./configure --enable-sni
make
sudo make install

Then wolfMQTT:

./configure
make

Then you will have access to the TLS features in wolfMQTT.

afridali123 commented 2 years ago

that i m aware of that, but eventhough i did ./configure --enable-sni this one while running ./mqttclinet i need to pass -S by this i want to avoid that instead if HAVE_SNI is defined, then mqttCtx.host will be assigned to mTlsSnihostname

image

afridali123 commented 2 years ago

i want to tell wolfssl that take mqttCtx.host as sni host, where can i define that in wolfssl library

embhorn commented 2 years ago

Ah... You can use the -h parameter to specify the host. The -S is for servers that require the Server Name Indicator extension.

embhorn commented 2 years ago

Here is an example:

HiveMQ Cloud

./examples/mqttclient/mqttclient -h 833f87e253304692bd2b911f0c18dba1.s1.eu.hivemq.cloud -t -S -u wolf1 -w NEZjcm7i8eRjFKF -p 8883
afridali123 commented 2 years ago

i dont want to pass any parameters, i want already defined host server address in mqttCtx.host = "" in mqttclient.c

afridali123 commented 2 years ago

where can i define HAVE_SNI in wolfssl library ??

embhorn commented 2 years ago

When you configure wolfSSL with --enable-sni, the define for HAVE_SNI is added to the generated file wolfssl/options.h. This file is included by the wolfMQTT library.

afridali123 commented 2 years ago

how wolfMQTT linked to wolfssl in which file we can set this HAVE_SNI define so that wolfMQTT client example can work without any parameters

afridali123 commented 2 years ago

but when i run ./mqttclient its not working when i run ./mqttclient -S "host name" then only its working (TLS enabled)

embhorn commented 2 years ago

wolfMQTT client example can work without any parameters

It sounds like you want write your own client. The simple example is very straightforward and is a good basis for your project: https://github.com/wolfSSL/wolfMQTT/tree/master/examples/mqttsimple

afridali123 commented 2 years ago

yep i tried defining #define HAVE_SNI in mqttsimple.h and compiled code & its not working is it the right way

afridali123 commented 2 years ago

i hope you are getting my point

afridali123 commented 2 years ago

i want to run mqttclinet example without passing -S parameter since im already giving host in mqttCtx->host . how can i set that