Skip to content

Commit

Permalink
Bump bouncycastle jdk15on version to jdk18on 1.78.1 and associated ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
aaron-kumar committed May 19, 2024
1 parent 122b710 commit 9cac3cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Include dependency in your pom.xml:
<dependency>
<groupId>network.oxalis.pkix</groupId>
<artifactId>pkix-ocsp</artifactId>
<version>1.0.1</version>
<version>2.1.0</version>
</dependency>
```

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<bouncycastle.version>1.70</bouncycastle.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<httpclient.version>4.5.13</httpclient.version>
<testng.version>7.7.1</testng.version>
<mockito-core.version>4.11.0</mockito-core.version>
Expand Down Expand Up @@ -80,7 +80,7 @@
<!-- BouncyCastle -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>

Expand Down
31 changes: 17 additions & 14 deletions src/main/java/network/oxalis/pkix/ocsp/AbstractOcspClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
import network.oxalis.pkix.ocsp.builder.Properties;
import network.oxalis.pkix.ocsp.builder.Property;
import network.oxalis.pkix.ocsp.fetcher.UrlOcspFetcher;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.ASN1IA5String;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x509.AccessDescription;
import org.bouncycastle.asn1.x509.AuthorityInformationAccess;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
import org.bouncycastle.x509.extension.X509ExtensionUtil;
import org.bouncycastle.cert.jcajce.JcaX509ExtensionUtils;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

/**
Expand Down Expand Up @@ -79,15 +79,18 @@ protected URI detectOcspUri(X509Certificate certificate) throws OcspException {
}

try {
ASN1Sequence asn1Seq = (ASN1Sequence) X509ExtensionUtil.fromExtensionValue(extensionValue);
Enumeration<?> objects = asn1Seq.getObjects();

while (objects.hasMoreElements()) {
ASN1Sequence obj = (ASN1Sequence) objects.nextElement();
if (obj.getObjectAt(0).equals(X509ObjectIdentifiers.id_ad_ocsp)) {
ASN1TaggedObject location = (ASN1TaggedObject ) obj.getObjectAt(1);
if (location.getTagNo() == GeneralName.uniformResourceIdentifier) {
ASN1OctetString uri = (ASN1OctetString ) location.getObject();
AuthorityInformationAccess authInfo = AuthorityInformationAccess.getInstance(
JcaX509ExtensionUtils.parseExtensionValue(extensionValue));

for (AccessDescription accessDescription : authInfo.getAccessDescriptions())
{
ASN1ObjectIdentifier accessMethod = accessDescription.getAccessMethod();
GeneralName accessLocation = accessDescription.getAccessLocation();

if (X509ObjectIdentifiers.id_ad_ocsp.equals(accessMethod))
{
if (GeneralName.uniformResourceIdentifier == accessLocation.getTagNo()) {
ASN1IA5String uri = ASN1IA5String.getInstance(accessLocation.getName());
return URI.create(new String(uri.getOctets()));
}
}
Expand Down

0 comments on commit 9cac3cb

Please sign in to comment.