5454
5555import static net .ripe .rpki .commons .crypto .x509cert .X509CertificateInformationAccessDescriptor .*;
5656
57+ @ Getter
5758@ Slf4j (topic = "TA" )
5859public class TA {
5960
6061 public static final IpResourceSet ALL_RESOURCES_SET = IpResourceSet .parse ("AS0-AS4294967295, 0/0, 0::/0" );
6162
62- @ Getter
6363 private TAState state ;
64-
6564 private final ValidityPeriods validityPeriods ;
6665
6766 public static TA initialise (Config config ) throws GeneralSecurityException , IOException {
@@ -303,17 +302,22 @@ private Pair<TrustAnchorResponse, TAState> processRequest(final TrustAnchorReque
303302 revokeAllIssuedResourceCertificates (newTAState );
304303 }
305304
305+ // There are two cases when we need to re-issue the TA certificate:
306+ // 1. We explicitly ask for it by providing the --force-new-ta-certificate option
307+ // 2. The TA certificate publication point or the notification.xml URL has changed
308+
306309 // re-issue TA certificate if some of the publication points are changed
307- final Optional <String > whyReissue = taCertificateHasToBeReIssued (request , signCtx .taState .getConfig ());
308- if (whyReissue .isPresent ()) {
309- if (!options .hasForceNewTaCertificate ()) {
310- throw new OperationAbortedException ("TA certificate has to be re-issued: " + whyReissue .get () +
311- ", bailing out. Provide " + ProgramOptions .FORCE_NEW_TA_CERT_OPT + " option to force TA certificate re-issue." );
312- }
310+ final Optional <String > differentLocations = locationsAreDifferent (request , signCtx .taState .getConfig ());
313311
314- // copy new SIAs to the TA config
315- updateTaConfigUrls (request , signCtx );
312+ if (differentLocations .isPresent () && !options .hasForceNewTaCertificate ()) {
313+ throw new OperationAbortedException ("TA certificate has to be re-issued: " + differentLocations .get () +
314+ ", bailing out. Provide " + ProgramOptions .FORCE_NEW_TA_CERT_OPT + " option to force TA certificate re-issue." );
315+ }
316316
317+ if (options .hasForceNewTaCertificate () || differentLocations .isPresent ()) {
318+ if (differentLocations .isPresent ()) {
319+ updateTaConfigUrls (request , signCtx );
320+ }
317321 final KeyPair keyPair = decoded .getLeft ();
318322 final X509ResourceCertificate taCertificate = decoded .getRight ();
319323 final BigInteger nextSerial = nextIssuedCertSerial (state );
@@ -322,7 +326,7 @@ private Pair<TrustAnchorResponse, TAState> processRequest(final TrustAnchorReque
322326 signCtx .taState .getConfig ()
323327 );
324328 final X509ResourceCertificate newTACertificate = reIssueRootCertificate (keyPair ,
325- merge (ta0SiaDescriptors , request .getSiaDescriptors ()), taCertificate , nextSerial );
329+ merge (ta0SiaDescriptors , request .getSiaDescriptors ()), taCertificate , nextSerial );
326330
327331 TAStateBuilder taStateBuilder = new TAStateBuilder (newTAState );
328332 taStateBuilder .withCrl (newTAState .getCrl ());
@@ -344,7 +348,7 @@ private Pair<TrustAnchorResponse, TAState> processRequest(final TrustAnchorReque
344348 return Pair .of (new TrustAnchorResponse (request .getCreationTimestamp (), publishedObjects , taResponses ), newTAState );
345349 }
346350
347- private Optional <String > taCertificateHasToBeReIssued (TrustAnchorRequest taRequest , Config taConfig ) {
351+ private Optional <String > locationsAreDifferent (TrustAnchorRequest taRequest , Config taConfig ) {
348352 if (!taConfig .getTaCertificatePublicationUri ().equals (taRequest .getTaCertificatePublicationUri ())) {
349353 return Optional .of ("Different TA certificate location, request has '" +
350354 taRequest .getTaCertificatePublicationUri () + "', config has '" + taConfig .getTaCertificatePublicationUri () + "'" );
0 commit comments