Commit a8e58d6
authored
see rustls/pemfile#61, and [RUSTSEC-2025-0134](https://rustsec.org/advisories/RUSTSEC-2025-0134). see also, olix0r/kubert#432.
this branch updates the place where we invoke `rustls_pemfile::certs`
inside of `linkerd-meshtls` and `linkerd-app-integration`.
see <https://docs.rs/rustls-pemfile/latest/src/rustls_pemfile/lib.rs.html#85-93>
for a link to the original `certs()` function being replaced here:
```rust
// https://docs.rs/rustls-pemfile/latest/src/rustls_pemfile/lib.rs.html#85-93
pub fn certs(
rd: &mut dyn io::BufRead,
) -> impl Iterator<Item = Result<CertificateDer<'static>, io::Error>> + '_ {
iter::from_fn(move || read_one(rd).transpose()).filter_map(|item| match item {
Ok(Item::X509Certificate(cert)) => Some(Ok(cert)),
Err(err) => Some(Err(err)),
_ => None,
})
}
// https://docs.rs/rustls-pemfile/latest/src/rustls_pemfile/pemfile.rs.html
/// Extract and decode the next PEM section from `rd`.
///
/// - Ok(None) is returned if there is no PEM section read from `rd`.
/// - Underlying IO errors produce a `Err(...)`
/// - Otherwise each decoded section is returned with a `Ok(Some(Item::...))`
///
/// You can use this function to build an iterator, for example:
/// `for item in iter::from_fn(|| read_one(rd).transpose()) { ... }`
#[cfg(feature = "std")]
pub fn read_one(rd: &mut dyn io::BufRead) -> Result<Option<Item>, io::Error> {
Item::from_buf(rd).map_err(|err| match err {
pem::Error::Io(io) => io,
other => Error::from(other).into(),
})
}
```
in `rustls_pki_types`, we do this using the `PemObject` trait. this
provides facilities to read PEM files through various interfaces, but
`pem_slice_iter()` feels like the most natural fit here. this takes an
in-memory `&'a [u8]` byte slice representing the contents of a PEM file,
and returns an iterator yielding `CertificateDer` deserialized
certificates.
that closely follows the same interface that `certs()` (above) presented
us.
<https://docs.rs/rustls-pki-types/latest/rustls_pki_types/pem/trait.PemObject.html#method.pem_slice_iter>
---
* refactor: `rustls-pemfile` is a workspace dependency
Signed-off-by: katelyn martin <kate@buoyant.io>
* refactor: replace `rustls-pemfile` with `rustls-pki-types`
NB: code is not update here, only package manifests.
Signed-off-by: katelyn martin <kate@buoyant.io>
* chore(meshtls): update `rustls_pemfile::certs` call
this commit updates the place where we invoke `rustls_pemfile::certs`
inside of `linkerd-meshtls`.
see <https://docs.rs/rustls-pemfile/latest/src/rustls_pemfile/lib.rs.html#85-93>
for a link to the original `certs()` function being replaced here:
```rust
// https://docs.rs/rustls-pemfile/latest/src/rustls_pemfile/lib.rs.html#85-93
pub fn certs(
rd: &mut dyn io::BufRead,
) -> impl Iterator<Item = Result<CertificateDer<'static>, io::Error>> + '_ {
iter::from_fn(move || read_one(rd).transpose()).filter_map(|item| match item {
Ok(Item::X509Certificate(cert)) => Some(Ok(cert)),
Err(err) => Some(Err(err)),
_ => None,
})
}
// https://docs.rs/rustls-pemfile/latest/src/rustls_pemfile/pemfile.rs.html
/// Extract and decode the next PEM section from `rd`.
///
/// - Ok(None) is returned if there is no PEM section read from `rd`.
/// - Underlying IO errors produce a `Err(...)`
/// - Otherwise each decoded section is returned with a `Ok(Some(Item::...))`
///
/// You can use this function to build an iterator, for example:
/// `for item in iter::from_fn(|| read_one(rd).transpose()) { ... }`
#[cfg(feature = "std")]
pub fn read_one(rd: &mut dyn io::BufRead) -> Result<Option<Item>, io::Error> {
Item::from_buf(rd).map_err(|err| match err {
pem::Error::Io(io) => io,
other => Error::from(other).into(),
})
}
```
in `rustls_pki_types`, we do this using the `PemObject` trait. this
provides facilities to read PEM files through various interfaces, but
`pem_slice_iter()` feels like the most natural fit here. this takes an
in-memory `&'a [u8]` byte slice representing the contents of a PEM file,
and returns an iterator yielding `CertificateDer` deserialized
certificates.
that closely follows the same interface that `certs()` (above) presented
us.
<https://docs.rs/rustls-pki-types/latest/rustls_pki_types/pem/trait.PemObject.html#method.pem_slice_iter>
Signed-off-by: katelyn martin <kate@buoyant.io>
* chore(app/integration): update `rustls_pemfile::certs` calls
as with the previous commit, we update calls to `rustls_pemfile::certs`.
Signed-off-by: katelyn martin <kate@buoyant.io>
* refactor: use `AsRef<[u8]>` for byte slices
this polishes some type signatures. `CertificateDer::pem_slice_iter`
accepts a slice of bytes. we must, for various reasons such as dealing
with our `TestEnv` system, sometimes hold our PEM data in the form of a
UTF-8 string.
this commit uses `AsRef` to coerce types to a slice of bytes rather
than presenting these parameters as `&str` string slices, which is
needlessly specific.
Signed-off-by: katelyn martin <kate@buoyant.io>
* refactor: `rustls-webpki` is a workspace dependency
this crate is related to rustls-pki-types, and the feature flags we set
on rustls-webpki affects which flags are enabled on rustls-pki-types.
defining both as workspace dependencies should help make this
relationship slightly more discoverable.
Signed-off-by: katelyn martin <kate@buoyant.io>
* nit(app/integration): add `rustls-pki-typess/std` flag
strictly speaking, we need this feature flag.
it's enabled for us already as part of `linkerd-meshtls`'s dependency on
the `rustls-webpki/alloc` flag, which `linkerd-app-integration` in turns
depends on.
that said, it's nice to be extra clear that we depend upon the `std`
flag should that change in the future.
Signed-off-by: katelyn martin <kate@buoyant.io>
---------
Signed-off-by: katelyn martin <kate@buoyant.io>
1 parent 2ed52f2 commit a8e58d6
6 files changed
Lines changed: 32 additions & 37 deletions
File tree
- linkerd
- app/integration
- src
- meshtls
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1512 | 1512 | | |
1513 | 1513 | | |
1514 | 1514 | | |
1515 | | - | |
| 1515 | + | |
1516 | 1516 | | |
1517 | 1517 | | |
1518 | 1518 | | |
| |||
1980 | 1980 | | |
1981 | 1981 | | |
1982 | 1982 | | |
1983 | | - | |
| 1983 | + | |
1984 | 1984 | | |
1985 | 1985 | | |
1986 | 1986 | | |
| |||
3498 | 3498 | | |
3499 | 3499 | | |
3500 | 3500 | | |
3501 | | - | |
3502 | | - | |
3503 | | - | |
3504 | | - | |
3505 | | - | |
3506 | | - | |
3507 | | - | |
3508 | | - | |
3509 | | - | |
3510 | 3501 | | |
3511 | 3502 | | |
3512 | 3503 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
| 102 | + | |
102 | 103 | | |
103 | | - | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
0 commit comments