Skip to content

8369950: TLS connection to IPv6 address fails with BCJSSE due to IllegalArgumentException#28577

Closed
sercher wants to merge 9 commits intoopenjdk:masterfrom
sercher:JDK-8369950
Closed

8369950: TLS connection to IPv6 address fails with BCJSSE due to IllegalArgumentException#28577
sercher wants to merge 9 commits intoopenjdk:masterfrom
sercher:JDK-8369950

Conversation

@sercher
Copy link
Contributor

@sercher sercher commented Dec 1, 2025

Hi all,

Let me propose a fix and a test case for JDK-8369950.

The failure reproduces with BCJSSE provider and all implementations of SSLSocket other than SSLSocketImpl.

In the test case an anonymous wrapper is used, over the standard SSLSocketImpl, to simulate an external JSSE provider. The test case shows the same behavior as in BCJSSE (failure due to non-LDH ASCII characters in the SNI host name).

The fix avoids constructing SNIHostName when the URL host name is an IPv4 or IPv6 literal address. Other than that, all other FQDN host names that have invalid characters (non-LDH ASCII characters) still produce that exception.

SNIHostName, as defined in

* As described in section 3, "Server Name Indication", of
* <A HREF="http://www.ietf.org/rfc/rfc6066.txt">TLS Extensions (RFC 6066)</A>,
* "HostName" contains the fully qualified DNS hostname of the server, as
* understood by the client. The encoded server name value of a hostname is
* represented as a byte string using ASCII encoding without a trailing dot.
* This allows the support of Internationalized Domain Names (IDN) through
* the use of A-labels (the ASCII-Compatible Encoding (ACE) form of a valid
* string of Internationalized Domain Names for Applications (IDNA)) defined
* in <A HREF="http://www.ietf.org/rfc/rfc5890.txt">RFC 5890</A>.
* <P>
* Note that {@code SNIHostName} objects are immutable.
*
* @spec https://www.rfc-editor.org/info/rfc5890
* RFC 5890: Internationalized Domain Names for Applications (IDNA):
* Definitions and Document Framework
* @spec https://www.rfc-editor.org/info/rfc6066
* RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions
* @see SNIServerName
* @see StandardConstants#SNI_HOST_NAME
*
* @since 1.8
*/
public final class SNIHostName extends SNIServerName {

has the fully qualified DNS hostname of the server. As follows from the section 3, "Server Name Indication", RFC 6066, Literal IPv4 and IPv6 addresses are not permitted in "HostName".

The fix mirrors the behavior of SSLSocketImpl, that avoids constructing the SNIHostName from literal addresses. Please see

if (hostname != null && hostname.indexOf('.') > 0 &&
!hostname.endsWith(".") &&
!IPAddressUtil.isIPv4LiteralAddress(hostname) &&
!IPAddressUtil.isIPv6LiteralAddress(hostname)) {
try {
return new SNIHostName(hostname);

Testing:

  • standard jtreg tests goups showed no regressions
  • the new test passes with the fix and fails otherwise
  • passes also with BCJSSE in FIPS and standard mode
BCJSSE standard
STDOUT:
STDERR:
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.PropertyUtils getBooleanSecurityProperty
INFORMATION: Found boolean security property [keystore.type.compat]: true
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.PropertyUtils getStringSecurityProperty
INFORMATION: Found string security property [jdk.tls.disabledAlgorithms]: SSLv3, TLSv1, TLSv1.1, DTLSv1.0, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, ECDH, TLS_RSA_*, rsa_pkcs1_sha1 usage HandshakeSignature, ecdsa_sha1 usage HandshakeSignature, dsa_sha1 usage HandshakeSignature
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.tls.disabledAlgorithms': rsa_pkcs1_sha1 usage HandshakeSignature
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.tls.disabledAlgorithms': ecdsa_sha1 usage HandshakeSignature
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.tls.disabledAlgorithms': dsa_sha1 usage HandshakeSignature
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.PropertyUtils getStringSecurityProperty
INFORMATION: Found string security property [jdk.certpath.disabledAlgorithms]: MD2, MD5, SHA1 jdkCA & usage TLSServer, RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224, SHA1 usage SignedJAR & denyAfter 2019-01-01
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.certpath.disabledAlgorithms': SHA1 jdkCA & usage TLSServer
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.certpath.disabledAlgorithms': SHA1 usage SignedJAR & denyAfter 2019-01-01
Dez. 01, 2025 2:44:02 PM org.bouncycastle.jsse.provider.ProvTlsServer notifyHandshakeBeginning
INFORMATION: [server #1 @193b6d73] accepting connection from 0:0:0:0:0:0:0:1:56197
Dez. 01, 2025 2:44:03 PM org.bouncycastle.jsse.provider.ProvTlsServer notifyHandshakeComplete
INFORMATION: [server #1 @193b6d73] established connection with 0:0:0:0:0:0:0:1:56197
Dez. 01, 2025 2:44:08 PM org.bouncycastle.jsse.provider.ProvTlsServer notifyConnectionClosed
INFORMATION: [server #1 @193b6d73] disconnected from 0:0:0:0:0:0:0:1:56197
STATUS:Passed.
BCJSSE FIPS
STDOUT:
STDERR:
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.PropertyUtils getBooleanSecurityProperty
INFORMATION: Found boolean security property [keystore.type.compat]: true
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.PropertyUtils getStringSecurityProperty
INFORMATION: Found string security property [jdk.tls.disabledAlgorithms]: SSLv3, TLSv1, TLSv1.1, DTLSv1.0, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, ECDH, TLS_RSA_*, rsa_pkcs1_sha1 usage HandshakeSignature, ecdsa_sha1 usage HandshakeSignature, dsa_sha1 usage HandshakeSignature
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.tls.disabledAlgorithms': rsa_pkcs1_sha1 usage HandshakeSignature
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.tls.disabledAlgorithms': ecdsa_sha1 usage HandshakeSignature
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.tls.disabledAlgorithms': dsa_sha1 usage HandshakeSignature
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.PropertyUtils getStringSecurityProperty
INFORMATION: Found string security property [jdk.certpath.disabledAlgorithms]: MD2, MD5, SHA1 jdkCA & usage TLSServer, RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224, SHA1 usage SignedJAR & denyAfter 2019-01-01
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.certpath.disabledAlgorithms': SHA1 jdkCA & usage TLSServer
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints create
WARNUNG: Ignoring unsupported entry in 'jdk.certpath.disabledAlgorithms': SHA1 usage SignedJAR & denyAfter 2019-01-01
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.ProvTlsServer notifyHandshakeBeginning
INFORMATION: [server #1 @4d1e9767] accepting connection from 0:0:0:0:0:0:0:1:56184
Dez. 01, 2025 2:41:32 PM org.bouncycastle.jsse.provider.ProvTlsServer notifyHandshakeComplete
INFORMATION: [server #1 @4d1e9767] established connection with 0:0:0:0:0:0:0:1:56184
Dez. 01, 2025 2:41:37 PM org.bouncycastle.jsse.provider.ProvTlsServer notifyConnectionClosed
INFORMATION: [server #1 @4d1e9767] disconnected from 0:0:0:0:0:0:0:1:56184
STATUS:Passed.

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8369950: TLS connection to IPv6 address fails with BCJSSE due to IllegalArgumentException (Bug - P4)

Reviewers

Contributors

  • Mikhail Yankelevich <myankelevich@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28577/head:pull/28577
$ git checkout pull/28577

Update a local copy of the PR:
$ git checkout pull/28577
$ git pull https://git.openjdk.org/jdk.git pull/28577/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28577

View PR using the GUI difftool:
$ git pr show -t 28577

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28577.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 1, 2025

👋 Welcome back schernyshev! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 1, 2025

@sercher This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8369950: TLS connection to IPv6 address fails with BCJSSE due to IllegalArgumentException

Co-authored-by: Mikhail Yankelevich <myankelevich@openjdk.org>
Reviewed-by: djelinski, vyazici, dfuchs, myankelevich

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 161 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@djelinski, @dfuch, @myankelev, @vy) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added security security-dev@openjdk.org net net-dev@openjdk.org labels Dec 1, 2025
@openjdk
Copy link

openjdk bot commented Dec 1, 2025

@sercher The following labels will be automatically applied to this pull request:

  • net
  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@sercher sercher marked this pull request as ready for review December 1, 2025 14:17
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 1, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 1, 2025

Copy link
Member

@djelinski djelinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 1, 2025
@dfuch
Copy link
Member

dfuch commented Dec 1, 2025

Please make sure to run tier2 before integrating.

@sercher
Copy link
Contributor Author

sercher commented Dec 1, 2025

LGTM. Thanks!

@djelinski Thank you for review!

@sercher
Copy link
Contributor Author

sercher commented Dec 1, 2025

Please make sure to run tier2 before integrating.

@dfuch Thanks Daniel. The new test is in tier2, so far it passes in macOS and Linux. Windows takes more time with tier2...

@sercher
Copy link
Contributor Author

sercher commented Dec 2, 2025

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 2, 2025
@openjdk
Copy link

openjdk bot commented Dec 2, 2025

@sercher
Your change (at version 7d1a903) is now ready to be sponsored by a Committer.

@jaikiran
Copy link
Member

jaikiran commented Dec 2, 2025

Hello Sergey, the copyright year on HttpsClient will need an update from 2001, 2024, to 2001, 2025,

if (!(s instanceof SSLSocketImpl) &&
!IPAddressUtil.isIPv4LiteralAddress(host) &&
!(host.charAt(0) == '[' && host.charAt(host.length() - 1) == ']' &&
IPAddressUtil.isIPv6LiteralAddress(host.substring(1, host.length() - 1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The host value here comes from URL.getHost() which specifies that it returns an IPv6 address enclosed in []brackets. So what you have here looks fine to me.

One additional thing I would suggest is to make this protected String host field of this class final. It currently gets assigned in the constructor of the HttpClient and HttpsClient and making this final would give an extra assurance that its value will always be coming from URL.getHost() call.

These 2 sun.net.www.http.HttpClient and HttpsClient classes are internal to the JDK, so changing this protected field to final shouldn't cause any issues for application code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaikiran I think this deserves a separate issue. I could file a bug for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's OK with me if you don't change this field to final in this PR.

* terminate all hung threads after its timeout has expired,
* currently 3 minutes by default, but you might try to be
* smart about it....
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not too familiar with these style of tests, but it looks like there are several similar ones in the javax/net/ssl area. Would you know if these comments are still accurate and up to date? In other words, do we need these comments in this test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's clean this up in a follow-up PR. There's 60+ files with the same comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, doing this as a separate PR is fine with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaikiran Let me clean up the comments that are not anymore accurate in this particular PR. I personally try to avoid this type of changes that only touch the whitespace or comments blocks, including the copyright header ones, because they increase the number of connections between unrelated changes, that makes the fix less portable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sercher, it's OK if you leave the test in the current form. Just fixing the @summary test on the test definition should be enough. I have spoken to others and the agreement is that since we already have similar tests in this area, it probably is a better thing to let this test stay in this manner instead of devicing some new way to test this. Sorry about the previous guidance to update these test comments.

BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sslOS));
bw.write("HTTP/1.1 200 OK\r\n\r\n\r\n");
bw.flush();
Thread.sleep(5000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the sleep() necessary for this test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, copy/paste. Deserves a separate PR to clean up.

* Fork off the other side, then do your work.
*/
SubjectAltNameIPv6() throws Exception {
if (separateServerThread) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these if/else blocks needed or could we simplify the test to just expect the server and client to run as separate threads?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spoke to Daniel and I agree with him that it's OK to leave this in current form and if needed clean up as a follow up when doing the same for the rest of these tests.

* @test
* @bug 8369950
* @library /test/lib
* @summary TLS connection to IPv6 address fails with BCJSSE due to IllegalArgumentException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - as per the jtreg tag order recommendation, the @summary should come before the @library https://openjdk.org/jtreg/tag-spec.html#ORDER

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this test doesn't exercise the BouncyCastle provider. Would it be better to change this line to say:

@summary Test that the HttpsURLConnection does not set IPv6 address literals for SNI hostname during TLS handshake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - as per the jtreg tag order recommendation, the @summary should come before the @library https://openjdk.org/jtreg/tag-spec.html#ORDER

Thanks @jaikiran , i will update the order and the summary text. The BouncyCastle came here from the title of the issue.

@sercher
Copy link
Contributor Author

sercher commented Dec 2, 2025

Hello Sergey, the copyright year on HttpsClient will need an update from 2001, 2024, to 2001, 2025,

Thanks @jaikiran. That's correct. I will update the headers.

@sercher sercher marked this pull request as draft December 2, 2025 10:23
@openjdk openjdk bot removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 2, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright year needs a bump.

Comment on lines +477 to +478
!(host.charAt(0) == '[' && host.charAt(host.length() - 1) == ']' &&
IPAddressUtil.isIPv6LiteralAddress(host.substring(1, host.length() - 1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one more place in sun.net.www, which is in this very class, that

(host.charAt(0) == '[' && host.charAt(host.length() - 1) == ']') { return host.substring(1, host.length() - 1)

logic is practiced. Would it make sense to refactor this into a private static Optional<String> ipv6FromHost(String host) method, preferably with some short explanation in the method's Javadoc on why we do this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same thought occurred to me but I'd rather keep refactoring at a minimum in this PR.

Copy link
Member

@myankelev myankelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor comments

}

SSLSocketFactory sf = new SimpleSSLContext().get().getSocketFactory();
URL url = new URL("https://[::1]:" + serverPort + "/index.html");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
URL url = new URL("https://[::1]:" + serverPort + "/index.html");
URL url =
new URI("https://[::1]:" + serverPort + "/index.html").toURL();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the block is better readable without it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's deprecated since version 20 I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, ok, i read it wrong, apologies. URI is the modern one, exactly.

void doServerSide() throws Exception {
SSLServerSocketFactory sslssf =
new SimpleSSLContext().get().getServerSocketFactory();
SSLServerSocket sslServerSocket =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could you please keep the lines under 80 characters long. There are a few instances in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

*/
SubjectAltNameIPv6() throws Exception {
startServer();
startClient();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it might be better to call doClientSide here directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, accepted.

/*
* Is the server ready to serve?
*/
volatile static boolean serverReady = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be better to make this a CountDownLatch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, accepted.

}

void startServer() throws Exception {
serverThread = new Thread() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
serverThread = new Thread() {
serverThread = new Thread(() -> {

What do you think?

Copy link
Contributor Author

@sercher sercher Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. I will add it manually in a single commit.

@sercher
Copy link
Contributor Author

sercher commented Dec 2, 2025

/contributor add @myankelev

@openjdk
Copy link

openjdk bot commented Dec 2, 2025

@sercher
Contributor Mikhail Yankelevich <myankelevich@openjdk.org> successfully added.

@myankelev
Copy link
Member

Thanks for considering me as a contributor to this ticket! I really appreciate it.
I personally feel that my suggestions weren't extensive enough to require adding me as a contributor, so there is need for it unless you think it's appropriate.

Overall the ticket looks good, thank you for your updates!

@sercher
Copy link
Contributor Author

sercher commented Dec 3, 2025

@myankelev Thank you for in-depth review.

@sercher sercher requested a review from djelinski December 3, 2025 00:44
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(sslOS));
bw.write("HTTP/1.1 200 OK\r\n\r\n\r\n");
bw.flush();
sslSocket.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you removed the Thread.sleep, you can't close the socket without reading the request off the input stream; it will cause intermittent connection reset failures on Windows. You can use the readOneRequest method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @djelinski for spotting this. Added the method.

* @comment Add -Djavax.net.debug=all to the following line to enable SSL debugging
* @run main/othervm SubjectAltNameIPv6
* @comment Insert -Djavax.net.debug=all into the following lines to enable SSL debugging
* @run main/othervm SubjectAltNameIPv6 127.0.0.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we also test against IPv4, I'd remove the mention of IPv6 from the class name (e.g., SubjectAltNameIP) and @summary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

*/
conn.setSSLSocketFactory(wrapSocketFactory(sf));
conn.setSSLSocketFactory(wrapSocketFactory(sf,
sslSocket -> clientSSLSocket = sslSocket));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we first assert that clientSSLSocket == null before assignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method doClientSide() is called from constructor, the clientSSLSocket is non-static and was set to null. Therefore, it's the only assignment of clientSSLSocket per instance. Or do you mean the check must be in the the lambda-expr?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean something like:

Suggested change
sslSocket -> clientSSLSocket = sslSocket));
sslSocket -> {
assertNull(clientSSLSocket);
clientSSLSocket = sslSocket;
}));

To avoid double-assignment and eventually causing verification of the wrong value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made assertEquals instead, otherwise it shows an incorrect message - it prints the left hand operand as "expected" value, which in the case of assertNull is in the right hand operand.

conn.getInputStream();

var sniSN = clientSSLSocket.getSSLParameters().getServerNames();
if( sniSN != null && !sniSN.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if( sniSNif (sniSN

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

sercher and others added 3 commits December 4, 2025 14:26
Co-authored-by: Daniel Jelinski <djelinski1@gmail.com>
Co-authored-by: Volkan Yazıcı <volkan.yazici@oracle.com>
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 4, 2025
@sercher sercher requested a review from vy December 4, 2025 21:58
@sercher
Copy link
Contributor Author

sercher commented Dec 8, 2025

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 8, 2025
@openjdk
Copy link

openjdk bot commented Dec 8, 2025

@sercher
Your change (at version 36c0874) is now ready to be sponsored by a Committer.

@vy
Copy link
Contributor

vy commented Dec 8, 2025

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 8, 2025

Going to push as commit 7da9153.
Since your change was applied there have been 161 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 8, 2025
@openjdk openjdk bot closed this Dec 8, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Dec 8, 2025
@openjdk
Copy link

openjdk bot commented Dec 8, 2025

@vy @sercher Pushed as commit 7da9153.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated net net-dev@openjdk.org security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

6 participants