Skip to content

Make the ring dependency optional#173

Merged
djc merged 2 commits into
djc:mainfrom
a-kenji:ke-ring-optional
Jun 18, 2026
Merged

Make the ring dependency optional#173
djc merged 2 commits into
djc:mainfrom
a-kenji:ke-ring-optional

Conversation

@a-kenji

@a-kenji a-kenji commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Make the dependency on ring truly optional.
It is still used by default through the ring feature, but when disabling we don't depend on the ring dependency anymore.

This also means that the signature is now created by the configured crypto provider as opposed to unconditionally by ring, which was the case before. E.g.: Before, even without the ring dependency and with the aws-lc-rs feature enabled signing of the JWT token was done through the ring signatures.

When adding gcp_auth without any features enabled and without default features, it will not compile anymore and instead throw a compile_error!, which explains that we need at least one provider and how to enable it.

Which was in essence already the case, look at, when compiling with --no-default-features:

error[E0599]: no method named `with_native_roots` found for struct `HttpsConnectorBuilder<State>` in the current scope
  --> src/types.rs:40:14
   |
39 |           let https = HttpsConnectorBuilder::new()
   |  _____________________-
40 | |             .with_native_roots()
   | |             -^^^^^^^^^^^^^^^^^ method not found in `HttpsConnectorBuilder<WantsTlsConfig>`
   | |_____________|
   |

For more information about this error, try `rustc --explain E0599`.
error: could not compile `gcp_auth` (lib) due to 1 previous error

Closes: #153

Comment thread src/types.rs
Comment thread src/signer.rs Outdated
@a-kenji a-kenji force-pushed the ke-ring-optional branch 2 times, most recently from 1e21e11 to f0d0766 Compare June 18, 2026 10:39
@a-kenji

a-kenji commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the review so far!

I now split it up into two commits:

  • 7998f4b: This allows us to compile without any default crypto features and then rely on the application to provide the correct environment. This supercedes the compile error we would have thrown, instead we throw an error when the default provider can't be initialized. This also pulls rustls as a direct dependency, but that was in the dependency tree anyways.
  • f0d0766: The actual commit making ring optional, now gating all the actual signing logic behind either the ring, or aws-lc-rs feature.

Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
Comment thread src/types.rs Outdated
a-kenji added 2 commits June 18, 2026 16:28
For the token providers that don't sign JWTs to keep working,
without a default feature, the HTTPS client must be able to pick up a crypto
provider at runtime, for example through: `CryptoProvider::install_default()`.

Use the `with_provider_and_*` constructors, handing them a provider from
`default_provider()`: the `ring` or `aws-lc-rs` provider when the respective
feature is enabled (`ring` wins when both are),
otherwise the per-process default (which can error upon construction).

We also now depend on `rustls` directly to pull in the `CryptoProvider`.

Without this, `cargo check --no-default-features` fails to resolve the constructor:
```
error[E0599]: no method named `with_native_roots` found for struct
HttpsConnectorBuilder<State>` in the current scope
  --> src/types.rs:40:14
   |
39 |         let https = HttpsConnectorBuilder::new()
   |                     -
40 |             .with_native_roots()
   |             -^^^^^^^^^^^^^^^^^ method not found in
   |                               `HttpsConnectorBuilder<WantsTlsConfig>`
```
Make the dependency on `ring` truly optional.
It is still used by default through the `ring` feature,
but when disabling we don't depend on the `ring` dependency anymore.

This also means that the signature is now created by the configured
crypto provider as opposed to unconditionally by ring, which was the
case before. E.g.: Before, even without the `ring` dependency and with
the `aws-lc-rs` feature enabled signing of the `JWT` token was done
through the `ring` signatures.

This also makes signing itself conditional on the crypto features.

Closes: djc#153
@a-kenji a-kenji force-pushed the ke-ring-optional branch from f0d0766 to 2d2bc3c Compare June 18, 2026 14:55
@djc djc merged commit 9152fac into djc:main Jun 18, 2026
6 checks passed
@djc

djc commented Jun 18, 2026

Copy link
Copy Markdown
Owner

LGTM, thanks!

@a-kenji

a-kenji commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the reviews!

@a-kenji a-kenji deleted the ke-ring-optional branch June 18, 2026 17:14
@flokli

flokli commented Jun 20, 2026

Copy link
Copy Markdown

Thanks! Is it possible to tag a release with this, so downstream consumers can use it?

@djc

djc commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Yup: 0.12.7.

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.

Make ring an optional dep

3 participants