Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access certificate with generic signed object parser #138

Merged
merged 6 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
return super.getSigningTime();
}

public X509ResourceCertificate getCertificate() {
Fixed Show fixed Hide fixed
ties marked this conversation as resolved.
Show resolved Hide resolved
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
Loading