Skip to content

Commit a5ed189

Browse files
committed
Inline method not available on JDK 16
1 parent 382da85 commit a5ed189

File tree

1 file changed

+22
-8
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl

1 file changed

+22
-8
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ssl/CertUtils.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import java.io.FileReader;
6262
import java.io.IOException;
6363
import java.math.BigInteger;
64-
import java.net.URI;
6564
import java.security.AlgorithmParameters;
6665
import java.security.InvalidKeyException;
6766
import java.security.KeyFactory;
@@ -86,6 +85,9 @@
8685
import java.security.spec.InvalidKeySpecException;
8786
import java.security.spec.InvalidParameterSpecException;
8887
import java.security.spec.PKCS8EncodedKeySpec;
88+
import java.time.ZoneId;
89+
import java.time.ZonedDateTime;
90+
import java.time.format.DateTimeFormatter;
8991
import java.util.ArrayList;
9092
import java.util.Base64;
9193
import java.util.Collection;
@@ -107,11 +109,7 @@
107109
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
108110
import com.oracle.truffle.api.TruffleFile;
109111
import com.oracle.truffle.api.nodes.Node;
110-
import java.time.ZoneId;
111-
import java.time.ZonedDateTime;
112-
import java.time.format.DateTimeFormatter;
113112

114-
import sun.security.provider.certpath.OCSP;
115113
import sun.security.util.DerValue;
116114
import sun.security.x509.AccessDescription;
117115
import sun.security.x509.AuthorityInfoAccessExtension;
@@ -121,6 +119,7 @@
121119
import sun.security.x509.GeneralNameInterface;
122120
import sun.security.x509.GeneralNames;
123121
import sun.security.x509.URIName;
122+
import sun.security.x509.X509CertImpl;
124123

125124
public final class CertUtils {
126125

@@ -352,9 +351,24 @@ private static PTuple parseCAIssuers(X509Certificate cert, PythonObjectFactory f
352351

353352
@TruffleBoundary
354353
private static PTuple parseOCSP(X509Certificate cert, PythonObjectFactory factory) {
355-
URI ocsp = OCSP.getResponderURI(cert);
356-
if (ocsp != null) {
357-
return factory.createTuple(new String[]{ocsp.toString()});
354+
// Inlined from sun.security.provider.certpath.OCSP#getResponderURI
355+
// Examine the certificate's AuthorityInfoAccess extension
356+
X509CertImpl certImpl = (X509CertImpl) cert;
357+
AuthorityInfoAccessExtension aia = certImpl.getAuthorityInfoAccessExtension();
358+
if (aia == null) {
359+
return null;
360+
}
361+
362+
List<AccessDescription> descriptions = aia.getAccessDescriptions();
363+
for (AccessDescription description : descriptions) {
364+
if (description.getAccessMethod().equals(
365+
(Object) AccessDescription.Ad_OCSP_Id)) {
366+
GeneralName generalName = description.getAccessLocation();
367+
if (generalName.getType() == GeneralNameInterface.NAME_URI) {
368+
URIName uri = (URIName) generalName.getName();
369+
return factory.createTuple(new String[]{uri.getURI().toString()});
370+
}
371+
}
358372
}
359373
return null;
360374
}

0 commit comments

Comments
 (0)