Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tomcat “什么意思?”;javax.net.ssl.SSLHandshakeException:服务器证书更改在重新协商期间受到限制”;如何预防呢?_Tomcat_Ssl_Java 7 - Fatal编程技术网

Tomcat “什么意思?”;javax.net.ssl.SSLHandshakeException:服务器证书更改在重新协商期间受到限制”;如何预防呢?

Tomcat “什么意思?”;javax.net.ssl.SSLHandshakeException:服务器证书更改在重新协商期间受到限制”;如何预防呢?,tomcat,ssl,java-7,Tomcat,Ssl,Java 7,我们使用OracleJDK1.7.071和Tomcat7.0.55。 不幸的是,在服务器之间的SSL连接期间,我们开始出现以下异常: javax.net.ssl.SSLHandshakeException: server certificate change is restrictedduring renegotiation 这意味着什么? 如何预防 Tomcat重新启动后,异常消失 完整堆栈: Caused by: javax.net.ssl.SSLHandshakeException: s

我们使用OracleJDK1.7.071和Tomcat7.0.55。 不幸的是,在服务器之间的SSL连接期间,我们开始出现以下异常:

javax.net.ssl.SSLHandshakeException: server certificate change is restrictedduring renegotiation
这意味着什么? 如何预防

Tomcat重新启动后,异常消失

完整堆栈:

Caused by: javax.net.ssl.SSLHandshakeException: server certificate change is restrictedduring renegotiation
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[?:1.7.0_71]
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884) ~[?:1.7.0_71]
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276) ~[?:1.7.0_71]
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:266) ~[?:1.7.0_71]
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1402) ~[?:1.7.0_71]
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:209) ~[?:1.7.0_71]
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:878) ~[?:1.7.0_71]
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:814) ~[?:1.7.0_71]
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016) ~[?:1.7.0_71]
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) ~[?:1.7.0_71]
        at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:702) ~[?:1.7.0_71]
        at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:122) ~[?:1.7.0_71]
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) ~[?:1.7.0_71]
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) ~[?:1.7.0_71]
        at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:506) ~[commons-httpclient-3.1.jar:?]
        at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) ~[commons-httpclient-3.1.jar:?]
        at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) ~[commons-httpclient-3.1.jar:?]
        at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) ~[commons-httpclient-3.1.jar:?]
        at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) ~[commons-httpclient-3.1.jar:?]
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) ~[commons-httpclient-3.1.jar:?]
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) ~[commons-httpclient-3.1.jar:?]
        at org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.executePostMethod(CommonsHttpInvokerRequestExecutor.java:205) ~[spring-web-3.2.9.RELEASE.jar:3.2.9.RELEASE]
        at org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor.doExecuteRequest(CommonsHttpInvokerRequestExecutor.java:140) ~[spring-web-3.2.9.RELEASE.jar:3.2.9.RELEASE]
        at org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor.executeRequest(AbstractHttpInvokerRequestExecutor.java:136) ~[spring-web-3.2.9.RELEASE.jar:3.2.9.RELEASE]
        at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:192) ~[spring-web-3.2.9.RELEASE.jar:3.2.9.RELEASE]
        at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.executeRequest(HttpInvokerClientInterceptor.java:174) ~[spring-web-3.2.9.RELEASE.jar:3.2.9.RELEASE]
        at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:142) ~[spring-web-3.2.9.RELEASE.jar:3.2.9.RELEASE]
        ... 160 more

客户端层代码中的此错误消息是最近Java更新中“SSL V3.0 Poodle漏洞-CVE-2014-3566”之后代码强化的结果。这是一个bug-如果您无法立即更新JRE,这里有一些解决方法:

第一个选项是在建立HTTPS连接时强制使用TLS协议:

如果您可以将HttpClient更新到比4.3.6更新的版本,则默认情况下将禁用SSLv3,并且您的代码不应再报告此类异常

如果无法升级HttpClient版本,则必须使用此应答代码将协议限制为TLS:

对于从Java 7运行时进行的其他http访问,必须设置以下系统属性

-Dhttps.protocols="TLSv1"
详细信息可在此处找到:


第二个选项是放宽客户端检查,以允许使用以下属性重新协商:

-Djdk.tls.allowUnsafeServerCertChange=true 
-Dsun.security.ssl.allowUnsafeRenegotiation=true

第三个选项是“改进”您的服务器证书,使其包括集群成员的所有IP地址,并根据


第四个选项是在添加此证书/重新协商检查之前,也就是在7u41(待确认)之前,降级您的Java版本


更新这个错误行为现在在JDK更新7u85和8u60中得到修复。感谢Pada找到了引用。

以下代码段在以下条件下在企业环境中为我们工作:

  • 无缝(运行时)证书更新是一项关键要求
  • 更新应用程序中使用的HTTPClient成本太高
  • 将https协议限制为“TLSv1”无效
  • 该应用程序是一个JNLP服务的java客户端,不允许通过JNLP参数将“allowUnsafeServerCertChange”和“allowUnsafeRenegotiation”传递给客户端应用程序(我猜JWS由于安全原因正在阻止它们)
  • 在应用程序引导期间,通过System.setProperty()调用设置“allowUnsafeServerCertChange”和“allowUnsafeRenegotiation”无效

    if (e.getCause() instanceof SSLHandshakeException) {
        logger.debug("server https certificate has been altered");
        try {
            Class<?> c = Class.forName("sun.security.ssl.ClientHandshaker");
            Field allowUnsafeServerCertChangeField = c.getDeclaredField("allowUnsafeServerCertChange");
            allowUnsafeServerCertChangeField.setAccessible(true);
            Field modifiersField = Field.class.getDeclaredField("modifiers");
            modifiersField.setAccessible(true);
            modifiersField.setInt(allowUnsafeServerCertChangeField, allowUnsafeServerCertChangeField.getModifiers() & ~Modifier.FINAL);
            allowUnsafeServerCertChangeField.set(null, true);
            logger.debug("client has been updated in order to support SSL certificate change (re-negotiation) on runtime.");
        }
        catch (Exception ex) {
            logger.debug("client cannot be updated to support SSL certificate change (re-negotiation) on runtime. Please restart the application.", ex);
        }
    }
    
    if(如SSLHandshakeException的getCause()实例){
    debug(“服务器https证书已更改”);
    试一试{
    Class c=Class.forName(“sun.security.ssl.ClientHandshaker”);
    字段allowUnsafeServerCertChangeField=c.getDeclaredField(“allowUnsafeServerCertChange”);
    allowUnsafeServerCertChangeField.setAccessible(true);
    字段修饰符字段=Field.class.getDeclaredField(“修饰符”);
    modifiersField.setAccessible(true);
    setInt(allowUnsafeServerCertChangeField、allowUnsafeServerCertChangeField.getModifiers()&~Modifier.FINAL);
    allowUnsafeServerCertChangeField.set(null,true);
    debug(“客户端已更新,以便在运行时支持SSL证书更改(重新协商)”;
    }
    捕获(例外情况除外){
    debug(“无法更新客户端以在运行时支持SSL证书更改(重新协商)。请重新启动应用程序。”,ex);
    }
    }
    

请注意这应被视为黑客攻击(引入漏洞),并应在受信任的环境中使用。在走这条路之前,应该尝试Yves答案中的所有选项。

这也可能是由于连接配置错误,例如haproxy的一个或多个负载平衡目标指向错误的IP地址,因此,X%的请求获得不同的证书。

我遇到这个问题是因为服务器端更新了它们的证书。在此之前,我们的客户工作得很好。我们只是重新启动了程序&它又恢复了正常。

我遇到了这个问题,结果是客户端在负载平衡器后面使用不同的证书调用服务

看起来您的服务器在重新协商期间发送了一个不同的证书。您是在运行时更改了证书还是配置了多个证书?否,一个执行SSL握手的证书“X”是什么意思*如果它是一个bug,它似乎并不是在所有情况下都被修复。我们在JDK1.8.0(40)上也看到了这一点,我担心所有这些选项对于JIRA和Confluence中的代码更改来说都是糟糕的解决方法。ApacheHttpClient 4.3.6似乎在默认情况下禁用了SSLv3,这意味着JIRA和Confluence也应该这样做。顺便说一句,SO包含了更多与Java8相关的细节!!!。为什么是JIRA和Confluence?我发现打嗝也会受到影响。这可能与HttpClient有关,也可能与最近发生变化的Spring行为有关?据我所知,导致此问题的代码是:现在似乎他们已经用:修复了它,因此修复将包含在:7u85&8u60中。我现在正在用
https.protocols=“TLSv1”运行Java 8u60
但部署的产品仍会遇到此错误。我已经提出了一个类似的问题,但是我使用的是Java1.8和HTTClient4.4.1,并且只使用TLSv1.2。请看你是否能帮忙——我同意。但在我的上下文中,它是相对于集群中的LDAP/SSL ActiveDirectory端点的,管理员似乎不愿意在两个端点上手动部署相同的证书,因为它破坏了自动续订机制。但你是对的,10年证书和正确的替代名称是最好的选择。