Commit Graph

56 Commits

Author SHA1 Message Date
Brian Smith ba29bbfce2 Move rcgen-based tests to their own crate.
Remove the `rcgen` dev-dependency from the webpki crate.
2023-10-08 10:31:11 -07:00
Brian Smith 764cc60bfa Tests: Remove redundant `tests` submodule in dos.rs.
The tests submodule was a holdover from when these were unit tests.
2023-10-08 10:31:11 -07:00
Brian Smith bfde8f3b3f Move DoS tests from unit tests to integration tests.
This is an intermediate step towards moving them into a separate crate.

Leave the `tests` submodule for now, to make the comparison with the
old (identical) code easier. The next commit will remove it and
re-indent the code.
2023-10-08 10:31:11 -07:00
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
Brian Smith ca2472ec5f NFC: Address Clippy `octal_escapes` lint. 2023-08-30 17:04:56 -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
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 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 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
Stiopa Koltsov ba54ede055 Error::UnsupportedCertWithoutExtensions
Better error than `BadDER` when certificate is generated incorrectly.

I agree to license my contributions to each file under the terms given at the top of each file I changed.
2021-02-17 14:39:43 -08:00
Stiopa Koltsov 1364e7a902 Error::UnsupportedCertVersion instead of BadDER on certificate v1
I agree to license my contributions to each file under the terms given at the top of each file I changed.
2021-02-17 14:37:35 -08:00
Brian Smith e8d040cefa Rename `TrustAnchor::from_x509_der` to `from_cert_der`. 2021-02-04 13:09:28 -08:00
Brian Smith b4b0afdf4e Move X.509-to-TrustAnchor parsing to `TrustAnchor`.
`trust_anchor_util` will now contain only the code generation functionality.
2021-01-25 21:49:15 -08:00
Matthew Mahnke 82c2e0b1b2 implement TryFrom for EndEntityCert 2021-01-12 11:01:44 -08:00
Brian Smith 28951a0d46 Don't enable *ring*'s `alloc` feature by default; Require `alloc` for RSA.
Only use *ring*'s `alloc` feature if webpki's `alloc` feature is enabled. This
disables RSA by default.

Adjust some tests that return different results depending on whether RSA is
available.
2021-01-07 13:08:30 -08:00
Brian Smith 2deeb79c74 Refactor features.
Test all feature configurations in CI.

Remove the `trust_anchor_utils` feature flag.

Guard all features that directly require allocation with a new `alloc` feature.
The RSA features will be handled separately.

Document the features. Tell docs.rs to document all features.

Adjust some tests so that tests are run in more configurations.
2021-01-07 00:36:28 -08:00
Brian Smith 64708f1b6a Tests: Remove superfluous `#[allow(box_pointers)]`. 2021-01-07 00:36:28 -08:00
Brian Smith 20a064ff80 Fix capitalization of `DNSName` and related names. 2020-12-29 14:28:56 -08:00
Brian Smith 0486ea10f6 `cargo fmt`. 2020-12-29 13:09:55 -08:00
Brian Smith 17a40df331 Stop using `#![forbid(...)]` and rely on Clippy in CI/CD instead.
Remove `#![forbid(warnings)]` since Rust Nightly changed the way it enforces it,
and broke the build.

Count on Clippy to catch warnings so that we don't get bothered to deal with
transient warnings while hacking on the code.
2020-12-07 17:57:08 -08:00
Brian Smith 6e2462ad18 Clippy: Address `clippy::single-component-path-imports` warnings. 2020-12-07 17:57:08 -08:00
Brian Smith 71a3415097 Clippy: Address `clippy::let-unit-value` warnings in integration tests. 2020-12-07 17:57:08 -08:00
Brian Smith 024bacce88 Clippy: Temporarily suppress `clippy::unreadable_literal`. 2020-12-07 17:57:08 -08:00
Brian Smith 8b741a41a1 Fix warning about `legacy_directory_ownership`.
Stop mentioning the now-removed warning.
2020-03-22 14:33:30 -05:00
Brian Smith 0d2699a389 Remove use of `untrusted` from the public API. 2019-07-15 21:25:11 -10:00
Brian Smith 8c73c9c9f1 `cargo +nightly fmt.` 2019-03-28 15:26:38 -10:00
Brian Smith 0d8a27161a Switch to Rust 2018 Edition. 2019-03-28 15:26:38 -10:00
Brian Smith b3bcccc38d Eliminate unnecessary `'static` lifetime annotations. 2019-03-28 15:19:47 -10:00
Brian Smith f2f2f13811 Revert "Revert "Remove support for SHA-1.""
This reverts commit db0c6cbd1e, i.e.
it removes SHA-1 support again.
2019-03-22 11:35:33 -10:00
Brian Smith faa7f2b88b Revert "`cargo +nightly fmt`."
This reverts commit 7379d6062b. We'll merge
some outstanding PRs before doing the reformat.
2019-01-29 17:06:47 -10:00
Brian Smith 7379d6062b `cargo +nightly fmt`. 2019-01-29 17:03:53 -10:00
Sebastian Hahn d139e98815 Add support for Ed25519 certificates
This adds support for verification of ed25519 certificates according to
RFC 8410. Implements #49.

The test certificate was generated using OpenSSL 1.1.1a, using the
following commands (CA.pl is distributed with OpenSSL):

openssl genpkey -algorithm ed25519 -outform pem -out root_key.pem
openssl req -new -x509 -days 9999 -extensions v3_ca -key root_key.pem \
-inform pem -outform pem -out root_ed25519.pem
echo root_ed25519.pem | CA.pl -newca

openssl genpkey -algorithm ed25519 -outform pem -out client_key.pem
openssl req -new -key client_key.pem -inform pem -outform pem \
-out client_ed25519_csr.pem
openssl ca -keyfile ./root_key.pem -days 999 -notext -in \
client_ed25519_csr.pem -out client_ed25519.pem

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2019-01-18 15:20:58 -10:00
Brian Smith db0c6cbd1e Revert "Remove support for SHA-1."
This reverts commit 97d336003e.

This will be done later.
2019-01-07 12:25:14 -10:00
Brian Smith 97d336003e Remove support for SHA-1.
All major browsers have removed support for SHA-1-signed certificates
from their Web PKI implementations. Let's do the same.
2018-11-28 13:41:41 -10:00
Brian Smith 2a48a8d30d Stop forbidding `fat_ptr_transmutes` feature removed before Rust 1.0.
rustc now warns about this line. Remove it since it was a no-op, as
`fat_ptr_transmutes` was removed before Rust 1.0 was released.
2018-01-10 13:00:55 -10:00
Brian Smith 551ccd2440 Fix --no-default-features build. 2017-08-31 16:47:47 -10:00
Brian Smith e4b95d781b Add IP address test vectors for DNS name parsing. 2017-08-31 14:15:01 -10:00
Brian Smith 047fb3ccfc Test underscores and hyphens in DNS names. 2017-08-31 13:07:30 -10:00
Brian Smith 937122ff74 Initial DNS name validation test vectors. 2017-08-31 13:07:29 -10:00
Brian Smith 84da242368 Forbid/deny all lints by default in integration tests. 2017-08-27 12:23:11 -10:00
Brian Smith 2f88818648 Only run trust_anchor_util tests if that feature is enabled. 2017-08-27 12:18:59 -10:00
Brian Smith 8e1eea0670 Fix `use` style in tests/integration.rs. 2017-08-27 12:18:34 -10:00
Brian Smith 1c0c6add49 Take `&TLSServerTrustAnchors` instead of moving it.
This allows webpki-roots, et al., to expose the trust anchors as a
`TLSServerTrustAnchors`.
2017-08-25 09:09:46 -10:00
Alex Gaynor 75f00b170a Use newtype for server trust anchors.
This is a step towards supporting TLS client authentication.
2017-08-25 09:07:42 -10:00
Brian Smith 222e4afdc1 Replace `impl From<SystemTime> for Time` with a `TryFrom`-like polyfill.
In particular, remove the `unwrap()` so we don't panic when given a
crazy time before the Unix epoch on systems capable of representing
such times.
2017-08-22 12:20:52 -10:00
Brian Smith 9eefad3c53 Rename `Time::from_seconds_from_unix_epoch()` to `from_seconds_since_unix_epoch()`.
The two different senses of `from` in the name were confusing & awkward.
2017-08-18 11:50:45 -10:00
Brian Smith 827d085673 Conform to draft Rust API guidelines regarding "std" feature name.
See https://rust-lang-nursery.github.io/api-guidelines/naming.html#feature-names-are-free-of-placeholder-words-c-feature.
2017-08-18 10:46:35 -10:00