Skip to content

Commit e659485

Browse files
author
Tim Bruijnzeels
authored
Merge release 0.9.3-rc3
2 parents f9c0232 + 6bf5ddd commit e659485

File tree

8 files changed

+192
-150
lines changed

8 files changed

+192
-150
lines changed

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
# Note: some of these values are also used when building Debian packages below.
33
name = "krill"
4-
version = "0.9.3-rc2"
4+
version = "0.9.3-rc3"
55
edition = "2018"
66
authors = [ "The NLnet Labs RPKI team <[email protected]>" ]
77
description = "Resource Public Key Infrastructure (RPKI) daemon"
@@ -44,7 +44,7 @@ rand = "^0.8"
4444
regex = { version = "^1.4", optional = true, default_features = false, features = ["std"] }
4545
reqwest = { version = "0.11", features = ["json"] }
4646
rpassword = { version = "^5.0", optional = true }
47-
rpki = { version = "0.13.1-rc1", features = [ "repository", "rrdp", "serde" ] }
47+
rpki = { version = "0.13.1-rc2", features = [ "repository", "rrdp", "serde" ] }
4848
# rpki = { version = "0.13.1-rc1", git = "https://github.com/NLnetLabs/rpki-rs/", features = [ "repository", "rrdp", "serde" ] }
4949
scrypt = { version = "^0.6", optional = true, default-features = false }
5050
serde = { version = "^1.0", features = ["derive"] }

Changelog.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# Change Log
22

3+
<<<<<<< HEAD
4+
## 0.9.3 (RC3) 'The Thundering Herd'
5+
6+
RC3 fixes the following issues in RC2:
7+
- Use the, now official, ASPA OID (#700)
8+
- Re-issue ASPA objects on key rolls (717)
9+
10+
=======
311
## 0.9.3 (RC2) 'The Thundering Herd'
412

13+
>>>>>>> main
514
This release adds the following features and fixes:
615
- Prevent a thundering herd of hosted CAs publishing at the same time (#692)
716
- Re-issue ROAs to ensure that short EE subject names are used (#700)

src/commons/api/ca.rs

+12
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,18 @@ impl IssuedCert {
335335
pub fn replaces(&self) -> Option<&ReplacedObject> {
336336
self.replaces.as_ref()
337337
}
338+
339+
/// Returns a (possibly empty) set of reduced applicable resources which is the intersection
340+
/// of the encompassing resources and this certificate's current resources.
341+
/// Returns None if the current resource set is not overclaiming and does not need to be
342+
/// reduced.
343+
pub fn reduced_applicable_resources(&self, encompassing: &ResourceSet) -> Option<ResourceSet> {
344+
if encompassing.contains(&self.resource_set) {
345+
None
346+
} else {
347+
Some(encompassing.intersection(&self.resource_set))
348+
}
349+
}
338350
}
339351

340352
impl PartialEq for IssuedCert {

src/daemon/ca/aspa.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
99
use std::{collections::HashMap, fmt::Debug};
1010

11-
use chrono::Duration;
1211
use rpki::repository::{
1312
aspa::{Aspa, AspaBuilder},
1413
sigobj::SignedObjectBuilder,
@@ -190,19 +189,24 @@ impl AspaObjects {
190189
Ok(object_updates)
191190
}
192191

193-
// Re-new ASPAs before they would expire
192+
// Re-new ASPAs, if the renew_threshold is specified, then
193+
// only objects which will expire before that time will be
194+
// renewed.
194195
pub fn renew(
195196
&self,
196197
certified_key: &CertifiedKey,
198+
renew_threshold: Option<Time>,
197199
issuance_timing: &IssuanceTimingConfig,
198200
signer: &KrillSigner,
199201
) -> KrillResult<AspaObjectsUpdates> {
200202
let mut updates = AspaObjectsUpdates::default();
201203

202-
let renew_threshold = Time::now() + Duration::weeks(issuance_timing.timing_aspa_reissue_weeks_before);
203-
204204
for aspa in self.0.values() {
205-
if aspa.expires() < renew_threshold {
205+
let renew = renew_threshold
206+
.map(|threshold| aspa.expires() < threshold)
207+
.unwrap_or(true); // always renew if no threshold is specified
208+
209+
if renew {
206210
let aspa_definition = aspa.definition().clone();
207211

208212
let new_aspa = self.make_aspa(aspa_definition, certified_key, issuance_timing, signer)?;

src/daemon/ca/child.rs

+106-8
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ use rpki::repository::{crypto::KeyIdentifier, x509::Time};
77
use crate::{
88
commons::{
99
api::{
10-
ChildCaInfo, ChildHandle, ChildState, IssuedCert, ResourceClassName, ResourceSet, SuspendedCert,
11-
UnsuspendedCert,
10+
ChildCaInfo, ChildHandle, ChildState, HexEncodedHash, IssuedCert, ReplacedObject, ResourceClassName,
11+
ResourceSet, Revocation, SuspendedCert, UnsuspendedCert,
1212
},
13-
crypto::IdCert,
13+
crypto::{CsrInfo, IdCert, KrillSigner, SignSupport},
1414
error::Error,
1515
KrillResult,
1616
},
17-
daemon::config::IssuanceTimingConfig,
17+
daemon::{
18+
ca::{CertifiedKey, ChildCertificateUpdates},
19+
config::IssuanceTimingConfig,
20+
},
1821
};
1922

2023
//------------ UsedKeyState ------------------------------------------------
@@ -184,6 +187,105 @@ impl ChildCertificates {
184187
self.issued.values()
185188
}
186189

190+
/// Re-issue everything when activating a new key
191+
pub fn activate_key(
192+
&self,
193+
new_key: &CertifiedKey,
194+
issuance_timing: &IssuanceTimingConfig,
195+
signer: &KrillSigner,
196+
) -> KrillResult<ChildCertificateUpdates> {
197+
let mut updates = ChildCertificateUpdates::default();
198+
for issued in self.issued.values() {
199+
updates.issue(self.re_issue(issued, None, new_key, issuance_timing, signer)?);
200+
}
201+
// Also re-issue suspended certificates, they may yet become unsuspended at some point
202+
for suspended in self.suspended.values() {
203+
updates.suspend(self.re_issue(suspended, None, new_key, issuance_timing, signer)?);
204+
}
205+
Ok(updates)
206+
}
207+
208+
/// Shrink any overclaiming certificates.
209+
///
210+
/// NOTE: We need to pro-actively shrink child certificates to avoid invalidating them.
211+
/// But, if we gain additional resources it is up to child to request a new certificate
212+
/// with those resources.
213+
pub fn shrink_overclaiming(
214+
&self,
215+
updated_key: &CertifiedKey,
216+
issuance_timing: &IssuanceTimingConfig,
217+
signer: &KrillSigner,
218+
) -> KrillResult<ChildCertificateUpdates> {
219+
let mut updates = ChildCertificateUpdates::default();
220+
221+
let updated_resources = updated_key.incoming_cert().resources();
222+
223+
for issued in self.issued.values() {
224+
if let Some(reduced_set) = issued.reduced_applicable_resources(updated_resources) {
225+
if reduced_set.is_empty() {
226+
// revoke
227+
updates.remove(issued.subject_key_identifier());
228+
} else {
229+
// re-issue
230+
updates.issue(self.re_issue(issued, Some(reduced_set), updated_key, issuance_timing, signer)?);
231+
}
232+
}
233+
}
234+
235+
// Also shrink suspended, in case they would come back
236+
for suspended in self.suspended.values() {
237+
if let Some(reduced_set) = suspended.reduced_applicable_resources(updated_resources) {
238+
if reduced_set.is_empty() {
239+
// revoke
240+
updates.remove(suspended.subject_key_identifier());
241+
} else {
242+
// re-issue shrunk suspended
243+
//
244+
// Note: this will not be published yet, but remain suspended
245+
// until the child contacts us again, or is manually
246+
// un-suspended.
247+
updates.suspend(self.re_issue(
248+
suspended,
249+
Some(reduced_set),
250+
updated_key,
251+
issuance_timing,
252+
signer,
253+
)?);
254+
}
255+
}
256+
}
257+
258+
Ok(updates)
259+
}
260+
261+
/// Re-issue a delegated certificate to replace an earlier
262+
/// one which is about to be outdated or has changed resources.
263+
fn re_issue(
264+
&self,
265+
previous: &IssuedCert,
266+
updated_resources: Option<ResourceSet>,
267+
signing_key: &CertifiedKey,
268+
issuance_timing: &IssuanceTimingConfig,
269+
signer: &KrillSigner,
270+
) -> KrillResult<IssuedCert> {
271+
let (_uri, limit, resource_set, cert) = previous.clone().unpack();
272+
let csr = CsrInfo::from(&cert);
273+
let resource_set = updated_resources.unwrap_or(resource_set);
274+
let replaced = ReplacedObject::new(Revocation::from(&cert), HexEncodedHash::from(&cert));
275+
276+
let re_issued = SignSupport::make_issued_cert(
277+
csr,
278+
&resource_set,
279+
limit,
280+
Some(replaced),
281+
signing_key,
282+
issuance_timing.timing_child_certificate_valid_weeks,
283+
signer,
284+
)?;
285+
286+
Ok(re_issued)
287+
}
288+
187289
pub fn expiring(&self, issuance_timing: &IssuanceTimingConfig) -> Vec<&IssuedCert> {
188290
self.issued
189291
.values()
@@ -200,10 +302,6 @@ impl ChildCertificates {
200302
.filter(|issued| !resources.contains(issued.resource_set()))
201303
.collect()
202304
}
203-
204-
pub fn iter(&self) -> impl Iterator<Item = &IssuedCert> {
205-
self.issued.values()
206-
}
207305
}
208306

209307
impl Default for ChildCertificates {

0 commit comments

Comments
 (0)