From 2a19b7ff0fd9440ab25ae98f9ed5fe3cce838aff Mon Sep 17 00:00:00 2001 From: Tigran Mkrtchyan Date: Mon, 5 Feb 2024 13:33:18 +0100 Subject: [PATCH] Merge pull request #2204 from kofemann/fix-ssl-param fix regression in SSLEngineConfigurator#setSSLParameters --- .../grizzly/ssl/SSLEngineConfigurator.java | 5 ++--- .../java/org/glassfish/grizzly/SSLTest.java | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLEngineConfigurator.java b/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLEngineConfigurator.java index 1c1adae6de..cf7b77dfbc 100644 --- a/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLEngineConfigurator.java +++ b/modules/grizzly/src/main/java/org/glassfish/grizzly/ssl/SSLEngineConfigurator.java @@ -1,6 +1,5 @@ /* - * Copyright 2023, 2024 Contributors to the Eclipse Foundation. - * Copyright (c) 2008, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -250,7 +249,7 @@ public SSLEngineConfigurator setWantClientAuth(boolean wantClientAuth) { * @return this SSLEngineConfigurator */ public SSLEngineConfigurator setSSLParameters(SSLParameters sslParameters) { - this.sslParameters = copy(this.sslParameters); + this.sslParameters = copy(sslParameters); return this; } diff --git a/modules/grizzly/src/test/java/org/glassfish/grizzly/SSLTest.java b/modules/grizzly/src/test/java/org/glassfish/grizzly/SSLTest.java index 614ecf7764..a262851e76 100644 --- a/modules/grizzly/src/test/java/org/glassfish/grizzly/SSLTest.java +++ b/modules/grizzly/src/test/java/org/glassfish/grizzly/SSLTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -17,6 +17,7 @@ package org.glassfish.grizzly; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -45,6 +46,7 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLHandshakeException; +import javax.net.ssl.SSLParameters; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; @@ -370,6 +372,22 @@ public void updated(Object result) { } + + @Test + public void testSetSSLParameters() { + + SSLContextConfigurator sslContextConfigurator = createSSLContextConfigurator(); + SSLEngineConfigurator serverSSLEngineConfigurator = new SSLEngineConfigurator(sslContextConfigurator.createSSLContext(true), false, false, false); + + assertFalse("Invalid initial value of NeedClientAuth", serverSSLEngineConfigurator.isNeedClientAuth()); + + SSLParameters sslParameters = new SSLParameters(); + sslParameters.setNeedClientAuth(true); + serverSSLEngineConfigurator.setSSLParameters(sslParameters); + + assertTrue("SSL params not propagated", serverSSLEngineConfigurator.isNeedClientAuth()); + } + // ------------------------------------------------------- Protected Methods protected void doTestPingPongFilterChain(boolean isBlocking, int turnAroundsNum, int filterIndex, Filter... filters) throws Exception {