Currently sqlx-rt uses native-tls. But library native-tls is dynamically linked and it's hard sometimes to set up the environment for it (ex. docker image).
But hopefully, there are rustls and tokio-rustls that can statically link SSL during compilation. I think it will be useful for many developers to have it.
Similar feature exists in actix-web.
It's not possible for Cargo to activate a feature dependent on another feature in a workable fashion. We would want tls-native and tls-rustls as features (perhaps with the first being default). tls-native would need to turn on tokio-tls _if_ runtime-tokio or async-native-tls _if_ runtime-actix-std.
So this is blocked on https://github.com/rust-lang/cargo/issues/3494
I definitely do want this though.
@mehcode Maybe there is some workaround for this, because we really need rustls. Or only a fork help in this case?
Besides, with rustls support we can build sqlx to musl target.
I'm not aware of a way to work-around this outside of a fork. If you can figure out a way, I'll merge a PR.
Besides, with rustls support we can build sqlx to musl target.
You can do that now by vendoring OpenSSL. We (LaunchBadge) do this for our production services.
See https://github.com/launchbadge/sqlx/issues/473#issuecomment-655517309
One way is to add two more features 'runtime-actix-rustls' and 'runtime-tokio-rustls' to sqlx-rt.
https://github.com/olvyko/sqlx/commit/0fd74fa0c9c8f16e55d540b89792b9946d776332
But as I see, sqlx-core depends on native-tls code that exported from sqlx-rt so it should be changed too
Sorry if this is a silly question, but is there a reason to not switch to rustls wholesale and get rid of native-tls?
One way is to add two more features 'runtime-actix-rustls' and 'runtime-tokio-rustls' to
sqlx-rt.
olvyko@0fd74fa
But as I see,sqlx-coredepends onnative-tlscode that exported fromsqlx-rtso it should be changed too
I don't think passing through the feature from one sqlx crate to another is a problem. The only problem I can see is that this is a breaking change. Since there is no default runtime, you also couldn't set a default [TLS backend + runtime combination] and it would have to be selected explicitly, like runtimes now.
@mehcode Would you be open to a PR that doubles the amount of "runtimes" by having a native-tls and a rustls variant of each (or triples it to also allow no tls)?
There's mostly API-identical alternatives to tokio-native-tls and async-native-tls: tokio-rustls and async-tls
tokio-rustls is being stubborn to convert to, though?
error[E0308]: mismatched types
--> sqlx-core/src/net/tls.rs:49:26
|
49 | .connect(host, stream)
| ^^^^ expected struct `sqlx_rt::tokio_rustls::webpki::DNSNameRef`, found `&str`
error[E0308]: mismatched types
--> sqlx-core/src/net/tls.rs:49:26
|
49 | .connect(host, stream)
| ^^^^ expected struct `sqlx_rt::tokio_rustls::webpki::DNSNameRef`, found `&str`
error[E0308]: try expression alternatives have incompatible types
--> sqlx-core/src/net/tls.rs:48:13
|
48 | / connector
49 | | .connect(host, stream)
50 | | .await
51 | | .map_err(|err| Error::Tls(err.into()))?,
| |_______________________________________________________^ expected enum `sqlx_rt::TlsStream`, found struct `sqlx_rt::tokio_rustls::client::TlsStream`
|
= note: expected enum `sqlx_rt::TlsStream<S>`
found struct `sqlx_rt::tokio_rustls::client::TlsStream<S>`
help: try using a variant of the expected enum
|
48 | sqlx_rt::TlsStream::Client(connector
49 | .connect(host, stream)
50 | .await
51 | .map_err(|err| Error::Tls(err.into()))?),
|
error[E0308]: try expression alternatives have incompatible types
--> sqlx-core/src/net/tls.rs:48:13
|
48 | / connector
49 | | .connect(host, stream)
50 | | .await
51 | | .map_err(|err| Error::Tls(err.into()))?,
| |_______________________________________________________^ expected enum `sqlx_rt::TlsStream`, found struct `sqlx_rt::tokio_rustls::client::TlsStream`
|
= note: expected enum `sqlx_rt::TlsStream<S>`
found struct `sqlx_rt::tokio_rustls::client::TlsStream<S>`
help: try using a variant of the expected enum
|
48 | sqlx_rt::TlsStream::Client(connector
49 | .connect(host, stream)
50 | .await
51 | .map_err(|err| Error::Tls(err.into()))?),
|
error[E0599]: no method named `get_ref` found for tuple `(&S, &dyn sqlx_rt::tokio_rustls::rustls::Session)` in the current scope
--> sqlx-core/src/net/tls.rs:170:51
|
170 | MaybeTlsStream::Tls(s) => s.get_ref().get_ref().get_ref(),
| ^^^^^^^ method not found in `(&S, &dyn sqlx_rt::tokio_rustls::rustls::Session)`
error[E0599]: no method named `get_ref` found for tuple `(&S, &dyn sqlx_rt::tokio_rustls::rustls::Session)` in the current scope
--> sqlx-core/src/net/tls.rs:170:51
|
170 | MaybeTlsStream::Tls(s) => s.get_ref().get_ref().get_ref(),
| ^^^^^^^ method not found in `(&S, &dyn sqlx_rt::tokio_rustls::rustls::Session)`
error[E0599]: no method named `get_mut` found for tuple `(&mut S, &mut dyn sqlx_rt::tokio_rustls::rustls::Session)` in the current scope
--> sqlx-core/src/net/tls.rs:189:51
|
189 | MaybeTlsStream::Tls(s) => s.get_mut().get_mut().get_mut(),
| ^^^^^^^ method not found in `(&mut S, &mut dyn sqlx_rt::tokio_rustls::rustls::Session)`
error[E0599]: no method named `get_mut` found for tuple `(&mut S, &mut dyn sqlx_rt::tokio_rustls::rustls::Session)` in the current scope
--> sqlx-core/src/net/tls.rs:189:51
|
189 | MaybeTlsStream::Tls(s) => s.get_mut().get_mut().get_mut(),
| ^^^^^^^ method not found in `(&mut S, &mut dyn sqlx_rt::tokio_rustls::rustls::Session)`
error: aborting due to 4 previous errors; 4 warnings emitted
Most helpful comment
Sorry if this is a silly question, but is there a reason to not switch to
rustlswholesale and get rid ofnative-tls?