From 2584917b8e0290703479d09e4123a046ba7c8baf Mon Sep 17 00:00:00 2001 From: Tigran Mkrtchyan Date: Mon, 5 Feb 2024 13:33:18 +0100 Subject: [PATCH] fix regression in SSLEngineConfigurator#setSSLParameters --- .../grizzly/ssl/SSLEngineConfigurator.java | 4 ++-- .../java/org/glassfish/grizzly/SSLTest.java | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 3 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 26793ef792..dcc94cd834 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,5 +1,5 @@ /* - * 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 @@ -249,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 {