Repository navigation
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When I want to connect the agent via MQTT and SSL to a MQTT broker the connection fails with a certificate error. If I enter the same login data and settings in another MQTT client the connections work without problems.
I use self created certificates. With and without the setting "allow untrusted certificates" this error occurs.
To Reproduce
Steps to reproduce the behavior:
- Enter MQTT data and enable SSL.
- Restart agent
- See error
Expected behavior
Successful connection to the MQTT broker
Misc info (please complete the following information):
- Windows build (ideally screenshot/info of
winver.exeoutput): - Windows' UI language: English
- HASS.Agent version: 2022.11.4
Please check what's applicable (multiple answers possible):
- Installed via installer
- Installed manually
- Problem occurs in HASS.Agent
- Problem occurs in Satellite Service
Logs
2022-06-11 16:12:22.951 +02:00 [INF] [MAIN] Extended logging enabled
2022-06-11 16:12:22.956 +02:00 [INF] [SETTINGS] Config storage path: C:\Users\*******\AppData\Roaming\LAB02 Research\HASS.Agent\config
2022-06-11 16:12:23.055 +02:00 [INF] [SETTINGS] Configuration loaded
2022-06-11 16:12:23.058 +02:00 [INF] [LOCALIZATION] Selected UI culture: [en] English
2022-06-11 16:12:23.269 +02:00 [INF] [SETTINGS_QUICKACTIONS] Loaded 3 entities
2022-06-11 16:12:23.271 +02:00 [INF] [SETTINGS_COMMANDS] Config not found, no entities loaded
2022-06-11 16:12:23.278 +02:00 [INF] [SETTINGS_SENSORS] Loaded 0 entities
2022-06-11 16:12:23.282 +02:00 [INF] [MQTT] Identifying as device: *******-PC
2022-06-11 16:12:23.282 +02:00 [INF] [SERVICE] Local install path: C:\Program Files (x86)\LAB02 Research\HASS.Agent Satellite Service
2022-06-11 16:12:23.282 +02:00 [INF] [NOTIFIER] Initializing local API ..
2022-06-11 16:12:23.285 +02:00 [INF] [HOTKEY] Completed bind for global quickaction hotkey
2022-06-11 16:12:23.294 +02:00 [INF] [MQTT] Connecting ..
2022-06-11 16:12:23.377 +02:00 [FTL] [PROGRAM] FirstChanceException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback.
System.Security.Authentication.AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback.
at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions)
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
LAB02-Admin commentedon Jun 11, 2022
Hey @DeerMaximum,
Don't actually use certs myself, so it's hard for me to determine exactly what's going wrong. I'll setup a test environment with mqtt certs, and see if I can reproduce/fix it :)
[hassagent-103]
LAB02-Admin commentedon Jun 17, 2022
Can you please show me the exact tls configuration of the working broker, ie. what certificates have you configured where? Perhaps a screenshot of the entire config.
Thanks!
DeerMaximum commentedon Jun 17, 2022
Here is the config:
The functioning broker is this one: Link
LAB02-Admin commentedon Jun 17, 2022
Well I can't for the life of me get it working with my staging setup, but that one's pretty messed up config-wise anyway.
I've made some changes in the mqtt connector, that should allow for self-signed certs when
allow untrusted certificatesis checked.Could you please follow these steps:
%appdata%\LAB02 Research\HASS.Agent)DeerMaximum commentedon Jun 17, 2022
With the test version it works if
allow untrusted certificatesis enabled. When disabled the same error still occurs.LAB02-Admin commentedon Jun 17, 2022
Ok, glad it's working. I presume the cert is self-signed, seeing as how you're using
homeassistant.localas the host, so it won't be a trusted certificate. You could locally import the CA cert as a root authority to have it trusted I guess.Closing this, but feel free to reopen if you think it should be implemented differently.
DeerMaximum commentedon Jun 18, 2022
I have imported the CA certificate into Windows and also imported it in the agent and in the other broker as root certificate. The certificate is validated and recognized in the other broker, but not in the agent.
Flightkick commentedon Aug 29, 2022
@LAB02-Admin
@DeerMaximum
Can confirm as well,
allow untrusted certificatesworks in the test version but not in the latest release.I also have the CA and intermediate certs installed in the Windows certificate store.
With the latest stable version I see the following error in the mqtt broker:
The message from OpenSSL seems to be a client error. I'm able to verify the certificate chain using
openssl s_client -showcerts -servername REDACTED -connect REDACTEDmanually on WSL, with the certs installed in it's own certificate store.Other clients are also able to connect without issues.
Maybe something down the MQTTnet stack uses OpenSSL which doesn't use the Windows certificate store?
LAB02-Admin commentedon Aug 30, 2022
@Flightkick, did you install the latest beta?
https://github.com/LAB02-Research/HASS.Agent/releases/tag/2022.13.0-beta2
Flightkick commentedon Aug 30, 2022
@LAB02-Admin, no I replaced the binaries with the test version as per your previous instructions.
Are you suggesting I should use the latest beta instead?
LAB02-Admin commentedon Aug 30, 2022
As a test, yes please
Flightkick commentedon Aug 31, 2022
@LAB02-Admin
Test results with the latest beta 2022.13.0-beta2
I am only able to connect to my self signed instance when
allow untrusted certificatesis ticked in the MQTT options. With that option disabled I get the following stacktrace:The MQTT module doesn't seem to use the Windows certificate store in which the self signed root CA and intermediate certificates are installed.
In my tests it did not matter whether a CA file was provided in the MQTT options or not.
The Home Assistant API module however does seem to honor the Windows certificate store, as unchecking the
allow untrusted certificatesoption works without any issues.JiDoan commentedon Mar 22, 2023
I have the same issue as well. I am using mqtts with clients using only username and password auth but Home Assistant is using a self signed cert to secure the auth. The root cert is trusted in Windows and works everywhere else, but not in HASS Agent. I also see
OpenSSL Error[0]: error:14094412:SSL routines:ssl3_read_bytes:sslv3 alert bad certificateon the Home Assistant MQTT logs but do not have HASS Agent configured to use a client cert. Maybe it is trying to send an empty cert which causes the issue?romanad commentedon Apr 9, 2023
Can't make work self-signed cert on latest stable agent version. MQTT Explorer and MQTTX work fine with mosquito broker. Please fix if possible.