question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OkHttp fails to set TLS v1.1 and v1.2 on JDK 7

See original GitHub issue

DESCRIPTION: OkHttp creates a SslSocketFactory using SSLContext.getInstance("TLS") to retrieve default TLS implementation from JDK. The last public version of JDK 7 (update 80) uses TLS v1 as default. This behavior has changed in new commercial versions by Oracle JDK 7 update 131 to use TLS v1.2 as default (the same behavior of JDK 8).

PROBLEM: When running my code on last JDK 7 public version (update 80), I’m not able to connect to servers that uses TLS v1.1 or TLS v1.2. The connectionsSpecs.tlsVersions feature does nothing because SSLContext.getInstance("TLS") retrieves v1 implementation.

SOLUTION: Change SSLContext.getInstance("TLS") to SSLContext.getInstance("TLSv1.2") so the JDK 7 will also retrieve TLS v1.2 by default and connectionsSpecs.tlsVersions feature will work as expected as TLS v1.2 can downgrade gracefully to previous versions.

Line to change: https://github.com/square/okhttp/blob/c3d6607a14f66eae3dedc927a3eff642d1493caa/okhttp/src/main/java/okhttp3/internal/platform/Platform.java#L269

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:19

github_iconTop GitHub Comments

2reactions
pangacommented, Jul 2, 2018

@yschimke Tests are green now!

2reactions
yschimkecommented, Jun 23, 2018

You should submit a PR next time, this felt a bit like

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Enable TLSv1.2 in OKHttp - ssl - Stack Overflow
As far as I know OKHttp does not include own SSL/TLS libraries, therefore it just uses the standard SSLSocket provided by Android.
Read more >
How to enable TLSv1.2 in Java 1.7 - Oracle Communities
to enable TLS, I upgraded my jdk to 1.7 update 99 and in the WL server startup options I set TLS params.
Read more >
Enabling TLS v1.2 in Java 7 | Baeldung
In this first example, we'll enable TLSv1.2 using SSLSocketFactory. First, we can create a default SSLSocketFactory object by calling the ...
Read more >
How To Enable Tlsv1.2 In Java 7U80 Client - ADocLib
Learn how to upgrade the SSL socket protocol to TLS 1.2 in Java 7. And while Java 7 supports TLSv1.2 the default is...
Read more >
Enable TLS 1.1 and 1.2 for Clients on Java 7 - Super User
You could just add the following property -Dhttps.protocols=TLSv1.1,TLSv1.2 which configures the JVM to specify which TLS protocol version ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found