在 Tomcat 8 上启用 javax.net.debug=all 会导致 HTTPS 中断,并出现“EC AlgorithmParameters 不可用”

在 Tomcat 8 上启用 javax.net.debug=all 会导致 HTTPS 中断,并出现“EC AlgorithmParameters 不可用”

在解决 Tomcat servlet 的问题时,我决定通过编辑/var/apache-tomcat-8.5.5/bin/setenv.sh并将行更改export JAVA_OPTS="-Xms512m -Xmx1536m -XX:MaxPermSize=256m"为 来启用网络调试export JAVA_OPTS="-Xms512m -Xmx1536m -XX:MaxPermSize=256m -Djavax.net.debug=all"。保存文件并重新启动 Tomcat(通过 catalina.sh start/stop)后,我发现我无法再连接到 Tomcat 管理器应用程序(https://10.9.9.236:8443/manager/html/) 通过 HTTPS。Chrome 说:

“无法访问该站点”(ERR_CONNECTION_CLOSED)

在完全停止并取消部署我的 web 应用程序后,我重现了此行为。(现在仅安装了默认的 Tomcat 管理器应用程序。)所以我知道只有一个 Java 选项导致 HTTPS 失败。

为什么启用调试会破坏 HTTPS?

以下是 catalina.out 日志文件中的一个可能的线索:

https-jsse-nio-8443-exec-4, fatal error: 80: problem unwrapping net record
java.lang.RuntimeException: java.security.NoSuchAlgorithmException: EC AlgorithmParameters not available
https-jsse-nio-8443-exec-4, SEND TLSv1.2 ALERT:  fatal, description = internal_error
https-jsse-nio-8443-exec-4, WRITE: TLSv1.2 Alert, length = 2
28-Sep-2016 14:01:00.576 SEVERE [https-jsse-nio-8443-exec-4] org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun 
 java.lang.RuntimeException: java.security.NoSuchAlgorithmException: EC AlgorithmParameters not available
    at sun.security.ssl.Handshaker.checkThrown(Handshaker.java:1429)
    at sun.security.ssl.SSLEngineImpl.checkTaskThrown(SSLEngineImpl.java:535)
    at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:813)
    at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
    at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
    at org.apache.tomcat.util.net.SecureNioChannel.handshakeUnwrap(SecureNioChannel.java:449)
    at org.apache.tomcat.util.net.SecureNioChannel.handshake(SecureNioChannel.java:227)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1387)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.security.NoSuchAlgorithmException: EC AlgorithmParameters not available
    at sun.security.util.ECUtil.getECParameters(ECUtil.java:100)
    at sun.security.util.ECUtil.getECParameterSpec(ECUtil.java:149)
    at sun.security.ssl.JsseJce.getECParameterSpec(JsseJce.java:385)
    at sun.security.ssl.SupportedEllipticCurvesExtension.toString(SupportedEllipticCurvesExtension.java:127)
    at sun.security.ssl.HelloExtensions.print(HelloExtensions.java:150)
    at sun.security.ssl.HandshakeMessage$ClientHello.print(HandshakeMessage.java:323)
    at sun.security.ssl.ServerHandshaker.clientHello(ServerHandshaker.java:340)
    at sun.security.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:221)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
    at sun.security.ssl.Handshaker$1.run(Handshaker.java:919)
    at sun.security.ssl.Handshaker$1.run(Handshaker.java:916)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.security.ssl.Handshaker$DelegatedTask.run(Handshaker.java:1369)
    at org.apache.tomcat.util.net.SecureNioChannel.tasks(SecureNioChannel.java:397)
    at org.apache.tomcat.util.net.SecureNioChannel.handshakeUnwrap(SecureNioChannel.java:457)
    ... 7 more
Caused by: java.security.NoSuchAlgorithmException: EC AlgorithmParameters not available
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
    at java.security.Security.getImpl(Security.java:695)
    at java.security.AlgorithmParameters.getInstance(AlgorithmParameters.java:146)
    at sun.security.util.ECUtil.getECParameters(ECUtil.java:98)
    ... 21 more

当我清除日志并恢复为默认的 JAVA_OPTS 时,异常不会发生。

环境:

CentOS Linux release 7.2.1511 (Core)
uname -r: 3.10.0-327.10.1.el7.x86_64

Using CATALINA_BASE:   /var/apache-tomcat-8.5.5
Using CATALINA_HOME:   /var/apache-tomcat-8.5.5
Using CATALINA_TMPDIR: /var/apache-tomcat-8.5.5/temp
Using JRE_HOME:        /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64/jre
Using CLASSPATH:       /var/apache-tomcat-8.5.5/bin/bootstrap.jar:/var/apache-tomcat-8.5.5/bin/tomcat-juli.jar
Using CATALINA_PID:    /var/apache-tomcat-8.5.5/tomcat.pid

我应该补充一点,即使 servlet 的 HTTPS 访问中断,我仍然可以通过 HTTP 访问它,例如http://10.9.9.236:8080/管理器/html/

答案1

javax.net.debug=all问题是,当尝试调试 SSL 连接(例如)时,OpenJDK 8 不支持椭圆曲线密码。

尝试更新Java-1.8.0-openjdk软件包来修复这个错误。

查看更多:java-1.8.0-openjdk 错误修复更新

相关内容