Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ureq-native-tls feature to actually use native-tls #471

Merged
merged 2 commits into from
Apr 1, 2024
Merged

Fix ureq-native-tls feature to actually use native-tls #471

merged 2 commits into from
Apr 1, 2024

Conversation

jirutka
Copy link
Contributor

@jirutka jirutka commented Mar 31, 2024

Description

Feature ureq-native-tls currently doesn't work because ureq requires the TLS
connector to be specified explicitly for native-tls:

native-tls enables an adapter so you can pass a
native_tls::TlsConnector instance to AgentBuilder::tls_connector.
Due to the risk of diamond dependencies accidentally switching on an
unwanted TLS implementation, native-tls is never picked up as a
default or used by the crate level convenience calls (ureq::get
etc) – it must be configured on the agent.
-- https://github.com/algesten/ureq#features

When ncspot is built with rspotify with ureq-native-tls, it's unable to
create an HTTPS connection:

[ncspot::spotify_api] [DEBUG] http error: Transport(Transport { kind: UnknownScheme, message: Some("cannot make HTTPS request because no TLS backend is configured"), url: Some(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("api.spotify.com")), port: None, path: "/v1/me/", query: None, fragment: None }), source: None })

Motivation and Context

rspotify currently doesn’t work when built with ureq-native-tls.

Dependencies

tls-native (optional)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

CI

Is this change properly documented?

Yes


Related to #402

Fixes hrkfdn/ncspot#1159

jirutka added 2 commits March 31, 2024 20:32
ureq-native-tls currently doesn't work because ureq requires the TLS
connector to be specified explicitly for native-tls:

> `native-tls` enables an adapter so you can pass a
> `native_tls::TlsConnector` instance to `AgentBuilder::tls_connector`.
> Due to the risk of diamond dependencies accidentally switching on an
> unwanted TLS implementation, `native-tls` is never picked up as a
> default or used by the crate level convenience calls (`ureq::get`
> etc) – it must be configured on the agent.
> -- https://github.com/algesten/ureq#features

When ncspot is built with rspotify with ureq-native-tls, it's unable to
create an HTTPS connection:

    [ncspot::spotify_api] [DEBUG] http error: Transport(Transport { kind: UnknownScheme, message: Some("cannot make HTTPS request because no TLS backend is configured"), url: Some(Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("api.spotify.com")), port: None, path: "/v1/me/", query: None, fragment: None }), source: None })
@jirutka jirutka changed the title Draft: Fix ureq-native-tls feature to actually use native-tls Fix ureq-native-tls feature to actually use native-tls Mar 31, 2024
@ramsayleung
Copy link
Owner

native-tls enables an adapter so you can pass a
native_tls::TlsConnector instance to AgentBuilder::tls_connector.
Due to the risk of diamond dependencies accidentally switching on an
unwanted TLS implementation, native-tls is never picked up as a
default or used by the crate level convenience calls (ureq::get
etc) – it must be configured on the agent.
-- https://github.com/algesten/ureq#features

If I understand correctly, if you want to use ureq-native-tls feature, you have to enable ureq-native-tls feature and also explictly add native-tls as dependency and set it up?

@jirutka
Copy link
Contributor Author

jirutka commented Apr 1, 2024

you have to enable ureq-native-tls feature and also explictly add native-tls as dependency and set it up?

You have to explicitly pass a native_tls::TlsConnector instance to AgentBuilder::tls_connector. native_tls is provided by the native-tls crate, so yeah, you have to add native-tls as a dependency.

@ramsayleung ramsayleung merged commit 38b95b8 into ramsayleung:master Apr 1, 2024
7 checks passed
@ramsayleung
Copy link
Owner

ramsayleung commented Apr 1, 2024

Thanks for the contribution :)

@jirutka jirutka deleted the ureq-native-tls branch April 1, 2024 19:25
@jirutka
Copy link
Contributor Author

jirutka commented Apr 1, 2024

Can you please release a new version soon? :)

This was referenced Apr 2, 2024
@ramsayleung
Copy link
Owner

ramsayleung commented Apr 2, 2024

Yeah, I've released the v0.13.1

jirutka added a commit to jirutka/ncspot that referenced this pull request Apr 2, 2024
reqwest uses native TLS, but rspotify with ureq currently uses rustls,
i.e. ncspot bundles rustls and is linked with system TLS library at the
same time.

This has already been fixed in 80da5a8,
but this commit has been reverted in
aeff120 due to a bug in rspotify that
was fixed in 0.13.1 (ramsayleung/rspotify#471).
jirutka added a commit to jirutka/ncspot that referenced this pull request Apr 2, 2024
reqwest uses native TLS, but rspotify with ureq currently uses rustls,
i.e. ncspot bundles rustls and is linked with system TLS library at the
same time.

This has already been fixed in 80da5a8,
but this commit has been reverted in
aeff120 due to a bug in rspotify that
was fixed in 0.13.1 (ramsayleung/rspotify#471).
hrkfdn pushed a commit to hrkfdn/ncspot that referenced this pull request Apr 4, 2024
* chore(deps): bump rspotify to 0.13.1

* Use native TLS only, don't mix it with rustls

reqwest uses native TLS, but rspotify with ureq currently uses rustls,
i.e. ncspot bundles rustls and is linked with system TLS library at the
same time.

This has already been fixed in 80da5a8,
but this commit has been reverted in
aeff120 due to a bug in rspotify that
was fixed in 0.13.1 (ramsayleung/rspotify#471).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Playlists, podcasts and browse not loading
2 participants