Skip to content

Commit

Permalink
fix regression in SSLEngineConfigurator#setSSLParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kofemann committed Feb 5, 2024
1 parent 4316ca1 commit 2584917
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
20 changes: 19 additions & 1 deletion modules/grizzly/src/test/java/org/glassfish/grizzly/SSLTest.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2584917

Please sign in to comment.