When TLS uses pre-shared keys the Handshake has no peer certs
See original GitHub issueJava 11’s TLS stack automatically supports pre-shared keys when attempting a repeat TLS connection to a server.
Unfortunately these TLS handshakes don’t have peer certificates and SSLSession.getPeerCertificates()
throws.
Without the peer certificates other things break including certificate pinning.
java.util.NoSuchElementException
at java.base/java.util.ArrayDeque.removeFirst(ArrayDeque.java:363)
at okhttp3.internal.tls.BasicCertificateChainCleaner.clean(BasicCertificateChainCleaner.java:58)
at okhttp3.CertificatePinner.check(CertificatePinner.java:166)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:358)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:300)
This is reproduced by CallTest.matchingPinnedCertificate()
on Java 11.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Taking a Closer Look at the SSL/TLS Handshake
The “Finished” message is then sent to indicate that the handshake is complete on the client side. The Finished message is encrypted, and...
Read more >How does TLS work? - Manning Publications
The key exchange is the most important part of the TLS handshake! Without it, there's obviously no symmetric key being negotiated.
Read more >The Transport Layer Security (TLS) Protocol Version 1.3
Once the handshake is complete, the peers use the established keys to protect the application-layer traffic. A failure of the handshake or other...
Read more >Transport Layer Security (TLS) Protocol ... - Oracle Help Center
pre_shared_key : A pre-shared key (PSK) is a shared secret that was previously shared between the two parties using some secure channel before...
Read more >RFC 9190 - EAP-TLS 1.3: Using the Extensible Authentication ...
Pre-Shared Key (PSK) authentication SHALL NOT be used except for resumption. The full handshake in EAP-TLS with TLS 1.3 always provides forward secrecy...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OpenJDK 11.0.3 works fine. It seems like another related bug was resolved in OpenJDK 11.0.3. TLS 1.3 resumed session does not retain peer certificate chain OpenJDK 11.0.3 Release note
@swankjesse We’ll probably close this issue?
@swankjesse We’ve faced strange exception after updating to 3.14.2 version and migrating to Java 11 from time to time requests fail with the exception:
As I see in
OkHostnameVerifier.verify()
session.getPeerCertificates()
returns null. works fine with java 8 and version 3.12.1 could those issues be connected?