我有一个在 JBoss 下运行的用 Java 编写的 REST API。最近我们将 JVM 从 1.6 更新到了 1.7。这开始导致只有我们正在连接的 Python 客户端出现问题。间歇性地,Python 客户端会出现握手失败。我们编写了一个非常简单的测试来重现问题:
import httplib2
for i in range(1,500):
print i
response, content = httplib2.Http(disable_ssl_certificate_validation=True).request('https://server.com:8443',)
给出以下输出:
.
.
.
64
65
66
67
Traceback (most recent call last):
File "api_test/test.py", line 6, in <module>
response, content = httplib2.Http(disable_ssl_certificate_validation=True).request('https://server.com:8443/rest/solidtumor/2012/id/50d3216c092c8554b8b9f384?glossary=true&api_key=APIKEY',)
File "/home/hostovic/api_test/httplib2/__init__.py", line 1445, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/home/hostovic/api_test/httplib2/__init__.py", line 1197, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/home/hostovic/api_test/httplib2/__init__.py", line 1133, in _conn_request
conn.connect()
File "/home/hostovic/api_test/httplib2/__init__.py", line 914, in connect
raise SSLHandshakeError(e)
httplib2.SSLHandshakeError: [Errno 1] _ssl.c:490: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
第 67 次调用在此运行中失败,但每次运行测试时它在不同的时间失败。
我们的其他客户端(Java、Groovy 和 Ruby)可以正常工作。
如果我将 JVM 切换回 1.6,故障就会停止。
我使用以下方法进行了 openssl 检查:
openssl s_client -connect server.com:8443
它返回了这个:
New, TLSv1/SSLv3, Cipher is EDH-RSA-DES-CBC3-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1.2
Cipher : EDH-RSA-DES-CBC3-SHA
Session-ID: 50E748EA341BB433EEBC7386C606313C2B8B86360ED71DC8F3B0A14A1579D91B
Session-ID-ctx:
Master-Key: 1007AC489D60FE2D818F71A5A6873D5BBF5B1770BEC31CDBF29D0562DB0D30A33D9EBBA8AD211B8E24B23494B20A6223
Key-Arg : None
Krb5 Principal: None
PSK identity: None
PSK identity hint: None
Start Time: 1357334762
Timeout : 300 (sec)
Verify return code: 0 (ok)
这似乎是正确的,但我不确定。如果每次通话都失败,那将是一回事,但只是随机失败真的很奇怪。有人见过这个吗?