inre / rust-mq

RustMQ is the MQTT client written on pure Rust.
MIT License
190 stars 28 forks source link

WIP: Update OpenSSL dependency to support newer versions #30

Closed timvisee closed 3 years ago

timvisee commented 5 years ago

This PR attempts to:

I've attempted to upgrade the openssl dependency to support newer OpenSSL versions (>1.0), this is a required upgrade to build on systems having newer packages. I explicitly said attempted because it isn't fully done yet. The upgrade required some refactoring, which needs some review. The current PR also left a single build error due to deprecation, for which I don't know what to do.


1. TLS versions

The SSL/TLS method selection for TLS 1.{0..2} now uses SslMethod::tls(), without an explicit TLS version. According to the documentation this is a valid replacement. Does this make the actual TLS version selection obsolete? Should we remove the match branches and just return tls()?

https://github.com/inre/rust-mq/blob/2e0a08b1a186a9e2945fb661179295bc3a8761c3/src/client/cli.rs#L136-L138

https://github.com/inre/rust-mq/blob/2e0a08b1a186a9e2945fb661179295bc3a8761c3/src/client/cli.rs#L315-L317

2. X509 file type PEM

I replaced X509FileType::PEM with SslFiletype::PEM in many places. I don't know whether this is a valid.

https://github.com/inre/rust-mq/blob/2e0a08b1a186a9e2945fb661179295bc3a8761c3/netopt/src/ssl.rs#L34-L35

https://github.com/inre/rust-mq/blob/2e0a08b1a186a9e2945fb661179295bc3a8761c3/netopt/src/ssl.rs#L44-L45

https://github.com/inre/rust-mq/blob/2e0a08b1a186a9e2945fb661179295bc3a8761c3/src/client/cli.rs#L159-L162

https://github.com/inre/rust-mq/blob/2e0a08b1a186a9e2945fb661179295bc3a8761c3/src/client/cli.rs#L338-L341

3. try_clone() removed

The try_clone() function on SslStreams has been removed in newer openssl versions because it is broken according to this. With no replacement, this breaks the try_clone() function in rust-mq. What to do about this? Should the Ssl branch (line 89 below) panic/return an error? Should the function be removed entirely?

https://github.com/inre/rust-mq/blob/2e0a08b1a186a9e2945fb661179295bc3a8761c3/netopt/src/tcp.rs#L86-L92


The PR also includes upgrades of other dependencies that didn't require refactoring, and fixes warnings produced by examples when running cargo test.

To build/test/use this PR, make sure to switch to the local crate paths in all Cargo.toml file, instead of using the public crate releases. So, for example, replace this:

"mqtt3" = "0.1" # { path = "mqtt3" }
"netopt" = "0.1" # { path = "netopt" }
"mqttc" = "0.1" # { path = "mqttc" }

with this:

"mqtt3" = { path = "mqtt3" }
"netopt" = { path = "netopt" }
"mqttc" = { path = "mqttc" }