Skip to content

Commit

Permalink
Access certificate with generic signed object parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ties committed Oct 31, 2023
1 parent ea842ac commit d73c7cf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ next (snapshot) release, e.g. `1.1-SNAPSHOT` after releasing `1.0`.

## Changelog

## 2023-10-31 1.36
* Access the certificate for the generic signed object parser.

## 2023-10-03 1.35
* Build targets JDK 11
* Prefixes in ROAs are sorted by (prefix, maxlength - missing first)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import net.ripe.rpki.commons.crypto.cms.ghostbuster.GhostbustersCms;
import net.ripe.rpki.commons.crypto.cms.manifest.ManifestCms;
import net.ripe.rpki.commons.crypto.cms.roa.RoaCms;
import net.ripe.rpki.commons.crypto.x509cert.X509ResourceCertificate;
import net.ripe.rpki.commons.util.RepositoryObjectType;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.joda.time.DateTime;

import java.security.cert.Certificate;
import java.util.Optional;

import static net.ripe.rpki.commons.util.RepositoryObjectType.*;
Expand All @@ -17,6 +19,10 @@ public DateTime getSigningTime() {
return super.getSigningTime();
}

public X509ResourceCertificate getCertificate() {

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
RpkiSignedObjectParser.getCertificate
; it is advisable to add an Override annotation.
return super.getCertificate();
}

public Optional<RepositoryObjectType> getRepositoryObjectType() {
final ASN1ObjectIdentifier contentType = getContentType();
if (AspaCms.CONTENT_TYPE.equals(contentType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ void should_parse_roa() throws IOException {
assertThat(parser.getSigningTime()).isEqualTo(DateTime.parse("2011-11-11T01:55:18+00:00"));
}

/**
* Parse an invalid object, but still extract validity period and signing time.
*/
@Test
void should_parse_generic() throws IOException {
GenericRpkiSignedObjectParser parser = parse("interop/aspa/BAD-profile-13-AS211321-profile-13.asa");

assertThat(parser.getSigningTime()).isEqualTo(DateTime.parse("2021-11-11T11:19:00Z"));

assertThat(parser.getCertificate().getValidityPeriod().getNotValidBefore()).isEqualTo(DateTime.parse("2021-11-11T11:14:00Z"));
}


private GenericRpkiSignedObjectParser parse(String path) throws IOException {
byte[] bytes = Resources.toByteArray(Resources.getResource(path));
Expand Down

0 comments on commit d73c7cf

Please sign in to comment.