我对 SSL 还很陌生,并且遇到了一些看似已知的问题。我的应用程序是 SSL 客户端,并调用另一个启用双向 SSL 的组件。两个组件中的证书都是正确的,并且连接有时工作正常。每个服务器都有自己的服务器证书和私钥,但根证书和中间证书相同。
服务器中的 SSL 检查是在 Apache SW LB 中完成的。
|-------------|
/ | Tomcat1 |
|-------------| / |-------------|
|---------->|Apache SW LB |/
| |-------------|\
| \
| \ |-------------|
|-----------| |------------| | | Tomcat 2 |
|SSL Client |---HTTPS--->|Hardware LB |------| |-------------|
|-----------| |------------| | |-------------|
| / | Tomcat3 |
| |-------------| / |-------------|
|---------->|Apache SW LB |/
|-------------|\
\
\|-------------|
| Tomcat4 |
|-------------|
有时我会收到如下错误:-
***
%% Invalidated: [Session-10, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256]
http-nio-8443-exec-10, SEND TLSv1.2 ALERT: fatal, description = bad_certificate
http-nio-8443-exec-10, WRITE: TLSv1.2 Alert, length = 2
[Raw write]: length = 7
0000: 15 03 03 00 02 02 2A ......*
http-nio-8443-exec-10, called closeSocket()
http-nio-8443-exec-10, handling exception: javax.net.ssl.SSLHandshakeException: server certificate change is restricted during renegotiation
我使用 Spring REST 模板来调用 REST 调用并仅使用 TLS_V1.2,但仍然收到上述错误。
TrustStrategy ts = new TrustStrategy() {
@Override
public boolean isTrusted(
X509Certificate[] x509Certificates, String s)
throws CertificateException {
return true; // TODO : revisit
}
};
SSLContext sslcontext = org.apache.http.ssl.SSLContexts.custom()
.loadKeyMaterial(keyStore, keypass.toCharArray())
.loadTrustMaterial(trustStore, ts)
.build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext, new String[] {
"TLSv1.2" }, null,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
}
在谷歌搜索上,我发现这个问题不会发生在 TLSv1.2 和 Java 8(java 版本“1.8.0_60”)上。我正在使用 Spring 4 RestTemplete 来调用休息调用。
我正在使用以下版本的 httpclient :-
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4.1</version>
</dependency>
由于我是 SSL 新手,所以我有几个问题要开始:-
1).这是 SSL 客户端还是 SSL 服务器问题?
2)。连接有时工作有时断开的真正原因是什么?失败的技术原因。
3)。这是否与客户端的缓存有关
如果有人能指出这个问题的真正解决方案,那就太好了。