Skip to content
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

TLS Bridge connect fails, Windows build #1439

Open
norbertmm opened this issue Oct 1, 2019 · 3 comments
Open

TLS Bridge connect fails, Windows build #1439

norbertmm opened this issue Oct 1, 2019 · 3 comments

Comments

@norbertmm
Copy link

Using mosquitto 1.6.2 broker with TLS and Bridge, Windows build, with client certificate for bridge connection, only first bridge connect succeeds.
Automatic reconnection fails on almost every retry, same behaviour as #154 and #691 and closely related to #478.
When using unencrypted private key file (bridge_keyfile), i.e. without DES, so no need to enter a passphrase interactively, also the first TLS connection attempt fails immediately.
Detailed analysis of the bug showed following situation:

  • on Windows #if defined(GLIBC) && defined(WITH_ADNS) is not true
  • therefore NOT 3-step connection establish in lib/net_mosq.c and src/broker.c
  • within net__socket_connect_tls() SSL_connect() fails and error is SSL_ERROR_WANT_READ
  • mosq->want_connect correctly set to true then
  • send__connect() fails in bridge__connect() after that, as:
    • packet__write() does not honor mosq->want_connect because of wrong #if defined(WITH_TLS) && !defined(WITH_BROKER)
    • it should be #if defined(WITH_TLS) only
  • but then we get stuck in mosquitto_main_loop() -- so it's only part of the fix
  • mosquitto_loop() in lib/loop.c handles mosq->want_connect==true well -- for reads and writes
  • but mosquitto_main_loop() in src/loop.c does not, unless when using 3-step connect, probably
    • in loop_handle_reads_writes() calls to net__socket_connect_tls(context) are missing

I will post a proposed bugfix patch here soon for your review ...

@norbertmm
Copy link
Author

norbertmm commented Oct 1, 2019

This is a possible bugfix (applies to 1.6.2). Tested only on windows, WITH_TLS.
diff1.txt

@ethsonliu
Copy link

Maybe I'm facing the same problem with you, see #1461. I'll try your solution later, and then feedback here.

@ethsonliu
Copy link

@norbertmm Sry, failed. If it's successfully in your environment, can you try my codes in #1461 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants