-
Notifications
You must be signed in to change notification settings - Fork 71
Panic with invalid key file #176
Comments
Please do :). I've been meaning to do an audit on all the unwraps but that never happened |
I can't promise an audit on all the unwraps but I will certainly do the ones that are causing issue for me in that function |
unwraps look few. The only one aside from the cert/ca/key is |
It would be nice if rumqtt could also support This caused panic for me. |
Hi, when given an invalid client key file, rumqtt panics with
'index out of bounds: the len is 0 but the index is 0'
.The stacktrace (included as an attachment) points to this line: https://github.com/AtherEnergy/rumqtt/blob/master/src/client/network.rs#L124 as the culprit.
The error happens during the code:
and if the dummy key bytes are replaced with the real key bytes there is no issue and everything works.
I would have expected
MqttClient::start
(andNetworkStreamBuilder::create_stream
) to instead return an error which says something about an invalid key instead of panicking.EDIT: that
unwrap
increate_stream
doesn't look great to me either, from looking at the source ofpemfile::rsa_private_keys
, it will return anErr
if there's invalid base64 after "-----BEGIN PRIVATE KEY-----" in the file: https://github.com/ctz/rustls/blob/master/rustls/src/pemfile.rsEDIT 2: I should also say that I'm very happy to put together a PR to fix this.
rumqtt_panic_backtrace.txt
The text was updated successfully, but these errors were encountered: