javax.net.ssl.SSLException:没有可用的PSK。无法恢复

Gil*_*ili 8 ssl networking java-11

我正在使用Jetty客户端发送外发请求。在Java 10下完美运行的代码突然在Java 11下获得以下异常:

javax.net.ssl.SSLException: No PSK available. Unable to resume.
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:129)
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
    at java.base/sun.security.ssl.ServerHello$T13ServerHelloConsumer.consume(ServerHello.java:1224)
    at java.base/sun.security.ssl.ServerHello$ServerHelloConsumer.onServerHello(ServerHello.java:984)
    at java.base/sun.security.ssl.ServerHello$ServerHelloConsumer.consume(ServerHello.java:872)
    at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444)
    at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1065)
    at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1052)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:999)
    at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.fill(SslConnection.java:511)
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:128)
    at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
    at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)
    at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
    at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:411)
    at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:305)
    at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:159)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
    at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
Run Code Online (Sandbox Code Playgroud)

在这里向Jetty提交了错误报告,但我想知道:错误消息实际上是什么意思?我的环境有问题吗?或者该错误是否表示Jetty未正确配置连接?

Ada*_*.IT 13

JDK 11中有一个错误:https : //bugs.openjdk.java.net/browse/JDK-8213202

您必须:

  • 等待JDK 12的发布
  • 或向后移植到JDK 11
  • 或使用以下命令行参数作为解决方法: -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2


bal*_*ick 7

由于来自 WALCZAK.IT 的 Adam 的回答对我不起作用,我发现最终的解决方案是添加TLSv1.3到您的 java 目录中 conf 下的jdk.tls.disabledAlgorithmsinjava.security文件中。

因此,在 下打开 java.security %JAVA_HOME%\conf,找到jdk.tls.disabledAlgorithms并追加, TLSv1.3

  • 这对我的 JDK 版本“jdk-11.0.2.jdk”有用 (2认同)
  • 这对我开放jdk-11.0.1很有用 (2认同)

小智 5

我找到了一个适合我的解决方案,将其添加到您的 gradle.properties 中。

Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
JAVA_TOOL_OPTIONS=-Dhttps.protocols=TLSv1.2
systemProp.http.proxyHost=fodev.org
systemProp.http.proxyPort=8118
systemProp.http.nonProxyHosts=*.jitpack.io, *.maven.org
systemProp.https.proxyHost=fodev.org
systemProp.https.proxyPort=8118
systemProp.https.nonProxyHosts=*.jitpack.io, *.maven.org
Run Code Online (Sandbox Code Playgroud)