Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Client Ordering of CipherSuites. #7452

Merged
merged 6 commits into from
Jan 2, 2023
Merged

Conversation

yschimke
Copy link
Collaborator

Follow up to #6407

For 5.x only, apply the client specified cipher ordering, which defaults to those selected by MODERN_TLS.

This may effect performance of connections, but clients can and should override if required. Specifically it is likely to be a difference in ordering from the JDK defaults, but those have changed with JDK releases, and these should be kept inline
with modern secure browsers.

@yschimke
Copy link
Collaborator Author

@swankjesse if we announce this change, we could also provide a utility to adopt the JDK platform defaults, for the supported set including ordering.

Thoughts?

@yschimke yschimke marked this pull request as ready for review September 17, 2022 18:05
@yschimke
Copy link
Collaborator Author

Possibly relevant https://go.dev/blog/tls-cipher-suites

# Conflicts:
#	okhttp/src/jvmTest/java/okhttp3/CallHandshakeTest.kt
@yschimke
Copy link
Collaborator Author

@swankjesse Thoughts on this?

@@ -111,7 +111,7 @@ public class CipherSuiteTest {
forJavaName("TLS_FAKE_NEW_CIPHER"));
}

@Test public void applyIntersectionRetainsSslPrefixes() throws Exception {
@Test public void applyIntersectionRetainsTlsPrefixes() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is happening here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahhh, I understand.

Copy link
Collaborator Author

@yschimke yschimke Jan 2, 2023

Choose a reason for hiding this comment

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

Yep, it needs to switch SSL -> TLS because it follows a different source.

// to match legacy i.e. the platform/provider
//
// Opting for 2 here and keeping MODERN_TLS in line with secure browsers.
cipherSuitesAsString.intersect(socketEnabledCipherSuites, CipherSuite.ORDER_BY_NAME)
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this is the behavior change of the PR? Retaining the caller’s order rather than retaining the socket’s order? I like it.

okhttp/src/jvmTest/java/okhttp3/CallHandshakeTest.kt Outdated Show resolved Hide resolved
TLS_AES_128_GCM_SHA256,
TLS_AES_256_GCM_SHA384,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a behavior change? I assume containsExactlyElementsOf is unordered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as containsExactly(Object...) but handles the Iterable to array conversion : verifies that actual contains exactly the elements of the given Iterable and nothing else in the same order.

// return client.connectionSpecs.first().cipherSuites!!.map { it.javaName }.intersect(defaultEnabledCipherSuites)
return defaultEnabledCipherSuites.intersect(
client.connectionSpecs.first().cipherSuites!!.map { it.javaName })
return client.connectionSpecs.first().cipherSuites!!.map { it.javaName }.intersect(defaultEnabledCipherSuites.toSet())
Copy link
Collaborator

Choose a reason for hiding this comment

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

... and this is the change to the test that matches the corresponding change to the production code. Makes sense.

@@ -111,7 +111,7 @@ public class CipherSuiteTest {
forJavaName("TLS_FAKE_NEW_CIPHER"));
}

@Test public void applyIntersectionRetainsSslPrefixes() throws Exception {
@Test public void applyIntersectionRetainsTlsPrefixes() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahhh, I understand.

# Conflicts:
#	okhttp/src/jvmTest/java/okhttp3/CallHandshakeTest.kt
@yschimke yschimke merged commit 4ae6ce4 into square:master Jan 2, 2023
@yschimke yschimke deleted the ordering branch May 27, 2023 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants