GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix OCSP Tests (#17114) · netty/netty@7aa3f1f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • handler-ssl-ocsp/src
    • main/java/io/netty/handler/ssl/ocsp
      • NoOcspResponderException.java
      • OcspClient.java
      • OcspServerCertificateValidator.java
    • test/java/io/netty/handler/ssl/ocsp
      • OcspClientTest.java
      • OcspServerCertificateValidatorTest.java
  • testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test
    • OCSPTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp/NoOcspResponderException.java‎

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2026 The Netty Project
3+
*
4+
* The Netty Project licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
package io.netty.handler.ssl.ocsp;
17+
18+
/**
19+
* Thrown internally by {@link OcspClient} if the certificate being checked does not specify any OCSP Responder.
20+
* <p>
21+
* This exception extends {@link NullPointerException} for backwards compatibility reasons.
22+
*/
23+
public final class NoOcspResponderException extends NullPointerException {
24+
/**
25+
* Create a new instance with the given message.
26+
* @param message The error message.
27+
*/
28+
public NoOcspResponderException(String message) {
29+
super(message);
30+
}
31+
}
Collapse file

‎handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp/OcspClient.java‎

Copy file name to clipboardExpand all lines: handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp/OcspClient.java
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ final class OcspClient {
104104
* @param issuer {@link X509Certificate} issuer of client certificate
105105
* @param validateResponseNonce Set to {@code true} to enable OCSP response validation
106106
* @param ioTransport {@link IoTransport} to use
107-
* @return {@link Promise} of {@link BasicOCSPResp}
107+
* @param responsePromise {@link Promise} of {@link BasicOCSPResp}
108108
*/
109109
static void query(final X509Certificate x509Certificate,
110110
final X509Certificate issuer, final boolean validateResponseNonce,
@@ -401,13 +401,15 @@ private static String parseOcspUrlFromCertificate(X509Certificate cert) {
401401
AuthorityInformationAccess aiaExtension = AuthorityInformationAccess.fromExtensions(holder.getExtensions());
402402

403403
// Lookup for OCSP responder url
404-
for (AccessDescription accessDescription : aiaExtension.getAccessDescriptions()) {
405-
if (accessDescription.getAccessMethod().equals(id_ad_ocsp)) {
406-
return accessDescription.getAccessLocation().getName().toASN1Primitive().toString();
404+
if (aiaExtension != null) {
405+
for (AccessDescription accessDescription : aiaExtension.getAccessDescriptions()) {
406+
if (accessDescription.getAccessMethod().equals(id_ad_ocsp)) {
407+
return accessDescription.getAccessLocation().getName().toASN1Primitive().toString();
408+
}
407409
}
408410
}
409411

410-
throw new NullPointerException("Unable to find OCSP responder URL in Certificate");
412+
throw new NoOcspResponderException("Unable to find OCSP responder URL in Certificate");
411413
}
412414

413415
static final class Initializer extends ChannelInitializer<SocketChannel> {
Collapse file

‎handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp/OcspServerCertificateValidator.java‎

Copy file name to clipboardExpand all lines: handler-ssl-ocsp/src/main/java/io/netty/handler/ssl/ocsp/OcspServerCertificateValidator.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ public void userEventTriggered(final ChannelHandlerContext ctx, final Object evt
168168

169169
Date current = new Date();
170170
Date thisUpdate = response.getThisUpdate();
171-
Date nextUpdate = response.getNextUpdate();
172-
if (thisUpdate == null || !current.after(thisUpdate) ||
171+
Date nextUpdate = response.getNextUpdate();
172+
if (thisUpdate == null || !current.after(thisUpdate) ||
173173
(nextUpdate != null && !current.before(nextUpdate))) {
174174
ctx.fireExceptionCaught(new IllegalStateException("OCSP Response is out-of-date"));
175175
return;
Collapse file

‎handler-ssl-ocsp/src/test/java/io/netty/handler/ssl/ocsp/OcspClientTest.java‎

Copy file name to clipboardExpand all lines: handler-ssl-ocsp/src/test/java/io/netty/handler/ssl/ocsp/OcspClientTest.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
class OcspClientTest extends AbstractOcspTest {
7474

7575
@ParameterizedTest
76-
@ValueSource(strings = {"https://netty.io", "https://apple.com"})
76+
@ValueSource(strings = {"https://apple.com"})
7777
void simpleOcspQueryTest(String urlString) throws IOException, ExecutionException, InterruptedException {
7878
HttpsURLConnection httpsConnection = null;
7979
try {
Collapse file

‎handler-ssl-ocsp/src/test/java/io/netty/handler/ssl/ocsp/OcspServerCertificateValidatorTest.java‎

Copy file name to clipboardExpand all lines: handler-ssl-ocsp/src/test/java/io/netty/handler/ssl/ocsp/OcspServerCertificateValidatorTest.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void connectUsingHttpAndValidateCertificateUsingOcspTest() throws Exception {
5959
@Override
6060
protected void initChannel(SocketChannel ch) {
6161
ChannelPipeline pipeline = ch.pipeline();
62-
pipeline.addLast(sslContext.newHandler(ch.alloc(), "netty.io", 443));
62+
pipeline.addLast(sslContext.newHandler(ch.alloc(), "apple.com", 443));
6363
pipeline.addLast(new OcspServerCertificateValidator(false, createDefaultTransport()));
6464
pipeline.addLast(new SimpleChannelInboundHandler<Object>() {
6565
@Override
@@ -81,7 +81,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
8181
}
8282
});
8383

84-
ChannelFuture channelFuture = bootstrap.connect("netty.io", 443);
84+
ChannelFuture channelFuture = bootstrap.connect("apple.com", 443);
8585
channelFuture.sync();
8686

8787
// Wait for maximum of 1 minute for Ocsp validation to happen
Collapse file

‎testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/OCSPTest.java‎

Copy file name to clipboardExpand all lines: testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/OCSPTest.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void testSimpleQueryTest() throws Exception {
6262
@Override
6363
protected void initChannel(SocketChannel ch) {
6464
ChannelPipeline pipeline = ch.pipeline();
65-
pipeline.addLast(sslContext.newHandler(ch.alloc(), "netty.io", 443));
65+
pipeline.addLast(sslContext.newHandler(ch.alloc(), "apple.com", 443));
6666
pipeline.addLast(new OcspServerCertificateValidator(false));
6767
pipeline.addLast(new SimpleChannelInboundHandler<>() {
6868
@Override
@@ -84,7 +84,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
8484
}
8585
});
8686

87-
ChannelFuture channelFuture = bootstrap.connect("netty.io", 443);
87+
ChannelFuture channelFuture = bootstrap.connect("apple.com", 443);
8888
channelFuture.sync();
8989

9090
// Wait for maximum of 1 minute for Ocsp validation to happen

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.