hivemq / mqtt-cli

MQTT CLI is a useful command line interface for connecting various MQTT clients supporting MQTT 5.0 and 3.1.1
https://hivemq.github.io/mqtt-cli/
Apache License 2.0
312 stars 47 forks source link

auth.server.cafile property specified in config.properties is not working #425

Closed dlowrey closed 2 months ago

dlowrey commented 3 months ago

Expected behavior

When config.properties contains valid values for:

auth.server.cafile
auth.client.cert
auth.client.key

I should be able to do operations like con, pub, sub without having to specify certificate information.

Actual behavior

When attempting to do a con via the interactive shell (started via mqtt sh), I only get:

No trusted certificate found

My colleagues and I have troubleshooted this all day (on Mac OSX and Windows), and we discovered that if we specify the --ca-cert option (con --ca-cert ...) everything works fine, and the other client certificate values get picked up from the config.properties files correctly.

To Reproduce

Must have a MQTT broker set up for mTLS.

Steps

Specify the below keys with valid values in your config.properties file:

auth.server.cafile
auth.client.cert
auth.client.key

Then start interactive shell

mqtt sh

And try to connect to a broker

con -i myIdentifier

Reproducer code

Details

I think a similar issue was opened previously: https://github.com/hivemq/mqtt-cli/issues/125, and we had some MacOSX users who had no issue with this using 4.13.0, but once they upgraded to 4.29.0 it broke.

LukasBrand commented 3 months ago

Hi @dlowrey, thank you for using the mqtt-cli!

This behavior is quite strange as both the properties configuration as well as the command line options use the same logic to setup mTLS..

Could you please give more details about the used formats and encryption algorithms used in your certificates and private key as well as your TLS properties file setup?

For reference, here are the supported TLS configurations and setup possibilities: https://hivemq.github.io/mqtt-cli/docs/tls A possible issue could be: In order to use TLS with your default values inside the properties configuration file, simply add -s or --secure.


More details:

The keystore loading uses a natural hierarchy to determine precedence over the security provider possibilities.

LukasBrand commented 3 months ago

https://hivemq.kanbanize.com/ctrl_board/22/cards/23977/details/

LukasBrand commented 2 months ago

I am closing this issue for now. Feel free to reopen anytime if the issue still persists after applying my proposed solution.