Commit Graph

369 Commits

Author SHA1 Message Date
Daniel McCarney 52f4db4b85 tests: add BetterTLS path building test suite.
[`git cherry-pick 4a39e2b67d4cddf58b0ea16dd821a04ee2240058`, with support
for Edition 2018 added by Brian.]

This commit introduces the Netflix BetterTLS[0]'s path building test
suite to the webpki integration tests.

This project has a test runner for Rustls that will stand up TLS servers
to exercise these tests but:

* It requires Go.
* It needs Rustls in order to do a full TLS handshake with the test
  servers.
* It's slower than testing the path building directly without the TLS
  bits.

To avoid these issues this commit takes a different approach and vendors
the exported path building test suite. This is a supported feature[1] of
the upstream project and allow us to directly test webpki's path
building against the test suite without needing Rustls or Go.

[0]: https://github.com/Netflix/bettertls
[1]: https://github.com/Netflix/bettertls#exporting-tests-to-run-outside-of-the-bettertls-executor
2023-09-29 21:50:11 -07:00
Daniel McCarney 519bcb6c23 verify_cert: check name constraints after sig. validation
Prior to this commit parsing and processing certificate name constraints
was done before validating a chain of signatures to a known trust
anchor. This increases the attack surface of these features, allowing an
adversary to force webpki to process name constraints on a crafted
certificate without needing to have that certificate issued by a trusted
entity.

This commit moves the parsing and processing of name constraints to
after building and verifying the chain of signatures to reduce the
potential for mischief.
2023-09-29 20:21:44 -07:00
Daniel McCarney 4d0cbba617 signed_data: fix code block missing close marker 2023-09-29 20:21:44 -07:00
Brian Smith 31987f3f09 Pin `rcgen` to 0.11.1 since 0.11.2 broke semver. 2023-09-29 20:21:44 -07:00
Daniel McCarney f566cf1b3b verify_cert: apply path building budget
This is intended to be complementary to the signature validation limit
fix and addresses briansmith/webpki#276 in the same manner as NSS
libmozpkix.
2023-09-29 19:06:31 -07:00
Joseph Birr-Pixton 3ee04be687 Add comment indicating source of signature budget 2023-09-29 19:06:31 -07:00
Joseph Birr-Pixton 636037e9da Track signature limit using `Budget` type 2023-09-29 19:06:31 -07:00
Brian Smith 4a71d475e6 NFC: Address Clippy `explicit_auto_deref`. 2023-08-30 17:04:56 -07:00
Brian Smith 177c39eee5 NFC: Address Clippy `clone_on_copy`. 2023-08-30 17:04:56 -07:00
Brian Smith 3e8d10d72c CI: Clean up Clippy configuration.
None of these lints are triggered.
2023-08-30 17:04:56 -07:00
Brian Smith ae7a99f281 NFC: Address Clippy `useless_asref`. 2023-08-30 17:04:56 -07:00
Brian Smith 6d409c9039 NFC: Address Clippy `redundant_closure`. 2023-08-30 17:04:56 -07:00
Brian Smith ca2472ec5f NFC: Address Clippy `octal_escapes` lint. 2023-08-30 17:04:56 -07:00
Brian Smith d16bafbba4 NFC: Address Clippy `needless_borrow` complaints. 2023-08-30 17:04:56 -07:00
Brian Smith ad1fe9288e Documentation: Stop hard-coding briansmith.org paths.
Let people find the docs on docs.rs.
2023-08-30 17:04:56 -07:00
Brian Smith c81f92e4e8 0.22.1 2023-08-30 14:48:28 -07:00
Daniel McCarney 30a108e080 verify_cert: enforce maximum number of signatures.
Cherry-picked from e473ee1ecb335d8efa3d4ceb2feb369f46b125f2 and modified
by Brian Smith. The main modifications were:

1. Maintain API compatibility with webpki 0.22.0.
2. (In `build_chain_inner`), stop immediately on fatal error, without
   considering any more paths. The point of having such fatal errors
   is to fail ASAP and avoid unneeded work in the failure case.
3. The test uses rcgen which requires Rust 1.67.0 or later. (I don't
   think the non-test MSRV of webpki changes though.)

The original commit message is below:

Pathbuilding complexity can be quadratic, particularly when the set of
intermediates all have subjects matching a trust anchor. In these cases
we need to bound the number of expensive signature validation operations
that are performed to avoid a DoS on CPU usage.

This commit implements a simple maximum signature check limit inspired
by the approach taken in the Golang x509 package. No more than 100
signatures will be evaluated while pathbuilding. This limit works in
practice for Go when processing real world certificate chains and so
should be appropriate for our use case as well.
2023-08-30 14:08:00 -07:00
Daniel McCarney 522cecd950 Cherry pick f0259b9588bab116c7dfbc62524b98794c90aaef: verify: break out build_chain recursion.
[`git cherry-pick f0259b9588bab116c7dfbc62524b98794c90aaef`, merged by Brian Smith.]

Crate-internal consumers of `build_chain` always pass `0` as the sub CA
count, only the `verify_cert.rs` internal recursion changes this
parameter.

This commit separates the external interface from the internal
recursion to remove one extra parameter from an already complicated
interface.
2023-08-30 14:08:00 -07:00
Brian Smith 0cd0b31beb Revert main branch crate contents to the 0.22.0 release contents.
Reset the crate contents (sources, tests, etc.)
to what they were at that commit, while retaining the newer CI
configuration.

The changes since the 0.22.0 release were primarily intended to
accomplish two goals:

* Fix and improve the GitHub Actions configuration.
* Prepare a 0.21.5 release that was backward compatible with 0.21.4
  but which also contained the improvements that were in 0.22.0.

0.21.5 was never released and will not be released. Therefore all
of the noise to facilitate the 0.21.5 release can just be deleted,
as long as we leave the CI changes that are necessary for GitHub
Actions to work correctly now.

The exact commands I used were:

```
git checkout \
    6c334a2cf5 \
    -- \
    Cargo.toml \
    LICENSE \
    README.md \
    src \
    tests \
    third-party
git rm src/trust_anchor_util.rs
```

Commit 6c334a2cf5 was the commit from
which 0.22.0 was released. It is confusing because the commit
immediately prior, 0b7cbf2d32, has
commit message "0.22.0". It appears that I merged the "0.22.0"
commit, expecting to `cargo publish` from that commit, but then
`cargo publish` failed. Then I added
6c334a2cf5 to fix `cargo publish`
and did the `cargo publish` from that commit. That's why I added
the `package` CI step at that time, to prevent this confusing
situation from happening again.

`trust_anchor_utils.rs` was not in 0.22.0; the `git checkout` didn't
delete it, so I had to do it separately.

I left the tests added subsequent to 0.22.0 in `tests/` (e.g.
`name_tests.rs`) since those tests pass with the 0.22.0 sources too.

Unfortunately, this requires disabling a bunch of Clippy lints, to
avoid modifying the contents from 0.22.0.

(I know it is confusing. It took me a while to figure it out myself
today.)
2023-08-30 08:31:51 -07:00
Brian Smith 8330c72930 CI: Use Ubuntu 22.04 on GitHub Actions & update Clippy config.
Get all GitHub Actions jobs passing again.

There are no Ubuntu 18.04 runners in GitHub Actions anymore, so use
22.04.

Update mk/* scripts to match what's in *ring*'s main branch;
some of these changes are required for Ubuntu 22.04. This also fixes
a typo in the invocation of `cargo clippy`.

Temporarily allow `clippy::explicit_auto_deref` to avoid source code
changes prior to the next 0.22.1 release. Tweak `dns_names_test.rs`
so that it doesn't trigger `clippy::octal_escapes` false positives.

Update `cargo deny` to the latest release and update deny.toml so
that the Unicode license will be accepted, matching *ring*'s
configuration.
2023-08-29 17:47:00 -07:00
Tim Düsterhus b481381e91 Fix typo in Rustdoc for verify_signature() 2021-12-13 22:06:46 -08:00
Brian Smith 97507d40ab Appease the newest stable Clippy. 2021-12-13 21:44:26 -08:00
Brian Smith 18cda8a5e3 Sync mk/ with *ring*. 2021-05-11 14:16:16 -07:00
Fabio Valentini 6e037e3de0 update base64 dev-dependency to 0.13 2021-05-07 15:30:49 -07:00
Brian Smith 17d9189981 Temporarily undo some renaming that can't be alised, to get back webpki 0.21.4 compat.
Make it easier to maintain support for Rustls 0.19.1 by restoring the webpki main branch to a
state compatible with webpki 0.21.4.
2021-05-07 15:12:11 -07:00
Brian Smith de7fb02d2e Restore `Time::try_from`. 2021-05-07 15:12:11 -07:00
Brian Smith 5d5c71095c Add more backward-compatibility aliases. 2021-05-07 15:12:11 -07:00
Brian Smith 5060c2b1af CI/CD: Remove optimization for repository owner's PRs.
This optimization was carried over from *ring*'s CI configuration, but it
is less important for this project, so eliminate it.
2021-04-26 18:38:46 -07:00
Brian Smith 6e77bb953e CI/CD: Use my forks of the third-party GitHub actions.
This is a step towards implementing GitHub's GitHub Actions security
hardening advice.

```
$ sed -ri 's|(uses: +)([^/]+)/([^@])|\1briansmith/\2-\3|g' .github/workflows/ci.yml
$ grep "uses:" .github/workflows/ci.yml | sort | uniq
      - uses: briansmith/actions-cache@v2
      - uses: briansmith/actions-checkout@v2
      - uses: briansmith/actions-rs-toolchain@v1
      - uses: briansmith/codecov-codecov-action@v1
```
2021-04-26 18:24:31 -07:00
Brian Smith 96a2a0ff1d Sync GitHub permissions/token handling with what *ring* does. 2021-04-23 11:45:02 -07:00
Brian Smith 2baa7f8ebc Remove `EndEntityCert::verify_is_valid_for_at_least_one_dns_name`.
This doesn't really do the thing we hoped it would do, and it's dead weight.
2021-04-22 13:19:33 -07:00
Brian Smith 650341c29f Add `DnsName` trait tests. 2021-04-22 13:11:12 -07:00
Brian Smith b31b588621 Add tests for `DnsNameRef` traits. 2021-04-22 13:11:12 -07:00
Brian Smith 81bd1e3fbf Add missing docs and check for missing docs during build. 2021-04-20 18:32:56 -07:00
Brian Smith 279933295a Move clippy configuration out of `lib.rs` and into clippy.sh.
Reduce sensitivity to the set of clippy lints over time.
2021-04-20 18:18:12 -07:00
Brian Smith 12ff6d2daa Reduce number of allowed clippy violations. 2021-04-20 18:18:12 -07:00
Brian Smith de79b0a683 Update clippy configuration to match *ring*'s. 2021-04-20 18:18:12 -07:00
Brian Smith 2208a22acd Use `impl Trait` instead of an unnecessarily-named parameter. 2021-04-10 22:05:07 -07:00
Brian Smith 6c334a2cf5 CI/CD: Add a `package` job. 2021-04-09 17:12:55 -07:00
Brian Smith 0b7cbf2d32 0.22.0. 2021-04-09 16:15:55 -07:00
Brian Smith cd59614740 Rename internal names to conform to Rust conventions. 2021-04-09 15:58:41 -07:00
Brian Smith 5b67fb92da Rename error variants according to Rust conventions. 2021-04-09 15:58:41 -07:00
Brian Smith 2cb889b7c5 Rename `TrustAnchor::from_cert_der` to `TrustAnchor::try_from_cert_der`. 2021-04-09 15:58:41 -07:00
Brian Smith bc6893f6ef Use Rust naming conventions for abbreviations. 2021-04-09 15:58:41 -07:00
Brian Smith 5fd730eb18 Disable some clippy pedantic lints. 2021-02-18 15:58:12 -08:00
Brian Smith 092393e2ef Time: Use `Self` more. 2021-02-18 13:56:23 -08:00
Brian Smith 4942c65d97 Tweak `AllowWildcards` to pass `clippy::needless-pass-by-value`. 2021-02-18 13:50:37 -08:00
Brian Smith 628b8d6d6f Remove `der::Value::tlv`.
This was added as a prerequisite for a feature that hasn't landed yet, but it
is currently unused. Further, it is using deprecated features of `untrusted`.
Remove it. We'll add it back if/when we need it, probably with a different
implementation.
2021-02-18 13:30:21 -08:00
Brian Smith 1d5f4bd649 Avoid using `as` to convert `u8` to `usize`.
Enable the clippy lint for this.
2021-02-18 12:30:28 -08:00
Brian Smith 0789a90d94 Avoid using `as` for conversions from `Tag` to `u8`.
*ring* added a safer way to do this conversion a while back.
2021-02-18 12:30:28 -08:00