Open EnricoMucelli opened 1 year ago
Same issue with both my own CA/certs as well as with test.mosquitto.org
UnsupportedCertVersion
error originates from the webpki crate, and means that the certificate is not X509v3. You can check if a local certificate is v3 using this command:
$ openssl x509 -in server.crt -noout -text | grep Version
Version: 3 (0x2)
To print remote certificate (eg. test.mosquitto.org
) we use another command:
$ echo | openssl s_client -showcerts -servername test.mosquitto.org \
-connect test.mosquitto.org:8883 2>/dev/null | openssl x509 -inform pem -noout -text | grep Version
Version: 1 (0x0)
We see that certificate for test.mosquitto.org
is not v3, so it won't be verified. This seems to me that perhaps verification is too strict, if we can't even connect to test.mosquitto.org
where other clients connect to it just fine.
I've also found that certificate needs to use X509v3 Subject Alternative Name
extension, and it needs to contain DNS:[$CN]
, where $CN
is the value of the CN field in the certificate. I think for some reason webpki
while verifying whether a certificate is valid for the host we try to connect to, it only looks at the collection of subject alternative names and doesn't look at CN??? Honestly I have no clue, but I've somehow got it to work.
I'm not an expert in TLS, so I don't know if this is intended behaviour or not? From a user's perspective, it seems that rumqttc
just refuses to connect to brokers other clients can connect to just fine.
Hi,
I'm trying out rumqttc and stumble on the same issue.
I'm trying to connect to mosquitto test brokers (https://test.mosquitto.org/), and when I try to connect to one listed as: "8883 : MQTT, encrypted, unauthenticated". Which states that I shall use the ca-cert file provided by mosquitto (mosquitto.org.crt). But when do try I get: "I/O: invalid peer certificate: Other(OtherError(UnsupportedCertVersion))".
HI, i'm trying to connect to mosquitto using the mosquitto.org.crt certificate, i've added it to the root certificates but when i start the app i get an infinite loop like this:
the function is this one :