8326233: Utils#copySSLParameters loses needClientAuth Setting
Reviewed-by: djelinski, jjiang, dfuchs
This commit is contained in:
parent
14f9aba921
commit
36246c975b
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -625,7 +625,12 @@ public final class Utils {
|
|||||||
p1.setMaximumPacketSize(p.getMaximumPacketSize());
|
p1.setMaximumPacketSize(p.getMaximumPacketSize());
|
||||||
// JDK 8 EXCL END
|
// JDK 8 EXCL END
|
||||||
p1.setEndpointIdentificationAlgorithm(p.getEndpointIdentificationAlgorithm());
|
p1.setEndpointIdentificationAlgorithm(p.getEndpointIdentificationAlgorithm());
|
||||||
p1.setNeedClientAuth(p.getNeedClientAuth());
|
if (p.getNeedClientAuth()) {
|
||||||
|
p1.setNeedClientAuth(true);
|
||||||
|
}
|
||||||
|
if (p.getWantClientAuth()) {
|
||||||
|
p1.setWantClientAuth(true);
|
||||||
|
}
|
||||||
String[] protocols = p.getProtocols();
|
String[] protocols = p.getProtocols();
|
||||||
if (protocols != null) {
|
if (protocols != null) {
|
||||||
p1.setProtocols(protocols.clone());
|
p1.setProtocols(protocols.clone());
|
||||||
@ -633,7 +638,6 @@ public final class Utils {
|
|||||||
p1.setSNIMatchers(p.getSNIMatchers());
|
p1.setSNIMatchers(p.getSNIMatchers());
|
||||||
p1.setServerNames(p.getServerNames());
|
p1.setServerNames(p.getServerNames());
|
||||||
p1.setUseCipherSuitesOrder(p.getUseCipherSuitesOrder());
|
p1.setUseCipherSuitesOrder(p.getUseCipherSuitesOrder());
|
||||||
p1.setWantClientAuth(p.getWantClientAuth());
|
|
||||||
return p1;
|
return p1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -57,7 +57,7 @@ import static org.testng.Assert.*;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8209137
|
* @bug 8209137 8326233
|
||||||
* @summary HttpClient[.Builder] API and behaviour checks
|
* @summary HttpClient[.Builder] API and behaviour checks
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @build jdk.test.lib.net.SimpleSSLContext
|
* @build jdk.test.lib.net.SimpleSSLContext
|
||||||
@ -271,6 +271,34 @@ public class HttpClientBuilderTest {
|
|||||||
try (var closer = closeable(builder)) {
|
try (var closer = closeable(builder)) {
|
||||||
assertTrue(closer.build().sslParameters().getProtocols()[0].equals("C"));
|
assertTrue(closer.build().sslParameters().getProtocols()[0].equals("C"));
|
||||||
}
|
}
|
||||||
|
// test defaults for needClientAuth and wantClientAuth
|
||||||
|
builder.sslParameters(new SSLParameters());
|
||||||
|
try (var closer = closeable(builder)) {
|
||||||
|
assertFalse(closer.build().sslParameters().getNeedClientAuth(),
|
||||||
|
"needClientAuth() was expected to be false");
|
||||||
|
assertFalse(closer.build().sslParameters().getWantClientAuth(),
|
||||||
|
"wantClientAuth() was expected to be false");
|
||||||
|
}
|
||||||
|
// needClientAuth = true and thus wantClientAuth = false
|
||||||
|
SSLParameters needClientAuthParams = new SSLParameters();
|
||||||
|
needClientAuthParams.setNeedClientAuth(true);
|
||||||
|
builder.sslParameters(needClientAuthParams);
|
||||||
|
try (var closer = closeable(builder)) {
|
||||||
|
assertTrue(closer.build().sslParameters().getNeedClientAuth(),
|
||||||
|
"needClientAuth() was expected to be true");
|
||||||
|
assertFalse(closer.build().sslParameters().getWantClientAuth(),
|
||||||
|
"wantClientAuth() was expected to be false");
|
||||||
|
}
|
||||||
|
// wantClientAuth = true and thus needClientAuth = false
|
||||||
|
SSLParameters wantClientAuthParams = new SSLParameters();
|
||||||
|
wantClientAuthParams.setWantClientAuth(true);
|
||||||
|
builder.sslParameters(wantClientAuthParams);
|
||||||
|
try (var closer = closeable(builder)) {
|
||||||
|
assertTrue(closer.build().sslParameters().getWantClientAuth(),
|
||||||
|
"wantClientAuth() was expected to be true");
|
||||||
|
assertFalse(closer.build().sslParameters().getNeedClientAuth(),
|
||||||
|
"needClientAuth() was expected to be false");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user