You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "jamesnetherton (via GitHub)" <gi...@apache.org> on 2026/08/07 08:08:52 UTC

[PR] http-pqc-j21: Replace httpclient5 test dependency with RestAssured [camel-quarkus-examples]

jamesnetherton opened a new pull request, #559:
URL: https://github.com/apache/camel-quarkus-examples/pull/559

   ## Summary
   - Removed the `httpclient5` test-scoped dependency from the http-pqc-j21 example
   - Rewrote the provider-specific TLS tests to use RestAssured's `SSLConfig.sslSocketFactory()` backed by a provider-specific `SSLContext`, instead of httpclient5's `SSLConnectionSocketFactory`
   - The explicit `setNamedGroups()` call was unnecessary since both BCJSSE and SunJSSE already read named groups from the `jdk.tls.namedGroups` system property set by the test profiles
   
   ## Test plan
   - [x] `mvn verify` passes — all 6 tests green (3 in PqcWithFallbackTest, 3 in PqcOnlyTest)
   - [ ] Verify native mode tests still pass with `-Dnative`
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] http-pqc-j21: Replace httpclient5 test dependency with RestAssured [camel-quarkus-examples]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton merged PR #559:
URL: https://github.com/apache/camel-quarkus-examples/pull/559


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] http-pqc-j21: Replace httpclient5 test dependency with RestAssured [camel-quarkus-examples]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #559:
URL: https://github.com/apache/camel-quarkus-examples/pull/559#discussion_r3736049253


##########
http-pqc-j21/src/test/java/org/acme/http/pqc/AbstractPqcTest.java:
##########
@@ -84,54 +76,31 @@ void testRestAssuredConnection() throws Exception {
     }
 
     void testHttpClientConnection(String securityProvider, boolean expectFailure) throws Exception {
-        boolean failedAsExpected = false;
-
         try {
             SSLContext sslContext = createSslContext(securityProvider);
-
-            // Create custom SSLConnectionSocketFactory that explicitly sets named groups
-            SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext) {
-                @Override
-                protected void prepareSocket(javax.net.ssl.SSLSocket socket) throws java.io.IOException {
-                    super.prepareSocket(socket);
-                    // Explicitly set named groups on the socket's SSL parameters
-                    String configuredGroups = System.getProperty("jdk.tls.namedGroups", "X25519MLKEM768");
-                    try {
-                        SSLParameters sslParams = socket.getSSLParameters();
-                        String[] namedGroupsArray = configuredGroups.split(",");
-                        for (int i = 0; i < namedGroupsArray.length; i++) {
-                            namedGroupsArray[i] = namedGroupsArray[i].trim();
-                        }
-                        sslParams.setNamedGroups(namedGroupsArray);
-                        sslParams.setProtocols(new String[] { "TLSv1.3" });
-                        socket.setSSLParameters(sslParams);
-                        LOG.info("Set named groups on socket: " + Arrays.toString(namedGroupsArray));
-                    } catch (Exception e) {
-                        LOG.warn("Could not set named groups on socket: " + e.getMessage());
-                    }
-                }
-            };
-
-            HttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create()
-                    .setSSLSocketFactory(sslSocketFactory)
-                    .build();
-
-            try (CloseableHttpClient httpClient = HttpClients.custom()
-                    .setConnectionManager(connectionManager)
-                    .build()) {
-
-                HttpGet request = new HttpGet("https://localhost:" + RestAssured.port + "/pqc/secure");
-                int responseStatus = httpClient.execute(request, HttpResponse::getCode);
-
-                if (expectFailure) {
-                    fail(securityProvider + " should have failed but got response status : " + responseStatus);
-                } else {
-                    assertTrue(responseStatus == 200, "Expected response status is 200");
-                }
+            SSLSocketFactory sslSocketFactory = new SSLSocketFactory(sslContext);

Review Comment:
   Good catch on both points. Fixed in 7fd7a013 — now using the 4-arg constructor with `STRICT_HOSTNAME_VERIFIER` and `TLSv1.3` protocol constraint.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] http-pqc-j21: Replace httpclient5 test dependency with RestAssured [camel-quarkus-examples]

Posted by "JiriOndrusek (via GitHub)" <gi...@apache.org>.
JiriOndrusek commented on code in PR #559:
URL: https://github.com/apache/camel-quarkus-examples/pull/559#discussion_r3735777853


##########
http-pqc-j21/src/test/java/org/acme/http/pqc/AbstractPqcTest.java:
##########
@@ -84,54 +76,31 @@ void testRestAssuredConnection() throws Exception {
     }
 
     void testHttpClientConnection(String securityProvider, boolean expectFailure) throws Exception {
-        boolean failedAsExpected = false;
-
         try {
             SSLContext sslContext = createSslContext(securityProvider);
-
-            // Create custom SSLConnectionSocketFactory that explicitly sets named groups
-            SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext) {
-                @Override
-                protected void prepareSocket(javax.net.ssl.SSLSocket socket) throws java.io.IOException {
-                    super.prepareSocket(socket);
-                    // Explicitly set named groups on the socket's SSL parameters
-                    String configuredGroups = System.getProperty("jdk.tls.namedGroups", "X25519MLKEM768");
-                    try {
-                        SSLParameters sslParams = socket.getSSLParameters();
-                        String[] namedGroupsArray = configuredGroups.split(",");
-                        for (int i = 0; i < namedGroupsArray.length; i++) {
-                            namedGroupsArray[i] = namedGroupsArray[i].trim();
-                        }
-                        sslParams.setNamedGroups(namedGroupsArray);
-                        sslParams.setProtocols(new String[] { "TLSv1.3" });
-                        socket.setSSLParameters(sslParams);
-                        LOG.info("Set named groups on socket: " + Arrays.toString(namedGroupsArray));
-                    } catch (Exception e) {
-                        LOG.warn("Could not set named groups on socket: " + e.getMessage());
-                    }
-                }
-            };
-
-            HttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create()
-                    .setSSLSocketFactory(sslSocketFactory)
-                    .build();
-
-            try (CloseableHttpClient httpClient = HttpClients.custom()
-                    .setConnectionManager(connectionManager)
-                    .build()) {
-
-                HttpGet request = new HttpGet("https://localhost:" + RestAssured.port + "/pqc/secure");
-                int responseStatus = httpClient.execute(request, HttpResponse::getCode);
-
-                if (expectFailure) {
-                    fail(securityProvider + " should have failed but got response status : " + responseStatus);
-                } else {
-                    assertTrue(responseStatus == 200, "Expected response status is 200");
-                }
+            SSLSocketFactory sslSocketFactory = new SSLSocketFactory(sslContext);

Review Comment:
   `new SSLSocketFactory(sslContext)` has two issues:
   1. Defaults to `BROWSER_COMPATIBLE_HOSTNAME_VERIFIER` (lenient) instead of strict
   2. Does not constrain the socket to TLS 1.3 — client could negotiate TLS 1.2, bypassing PQC
   
   ```suggestion
               SSLSocketFactory sslSocketFactory = new SSLSocketFactory(
                       sslContext,
                       new String[] { "TLSv1.3" },
                       null,
                       SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org