问题确实是TLS_DHE_DSS_WITH_AES_128_CBC_SHA
新版本的 OkHttp 淘汰了一个特定的密码套件。为了解决这个问题,可以使用代码来提供ConnectionSpec
@JesseWilson 建议的自定义实例。
ConnectionSpec.Builder obsoleteSpecBuilder = new ConnectionSpec.Builder(ConnectionSpec.COMPATIBLE_TLS);
obsoleteSpecBuilder = obsoleteSpecBuilder.cipherSuites("TLS_DHE_DSS_WITH_AES_128_CBC_SHA");
ConnectionSpec obsoleteSpec = obsoleteSpecBuilder.build();
okHttpClient.setConnectionSpecs(Arrays.asList(obsoleteSpec));
然而,根本问题是 Jetty 使用的密钥库和信任库没有任何有效的 RSA 或 DSA 密钥(有一个 DSA 密钥,但它在 2 年前过期。显然,日期检查在以前的测试中没有激活)。如果没有这些密钥,Jetty 就无法提供任何依赖于 RSA/DSA 的密码套件,因此一旦TLS_*DSS*
删除密码套件,客户端就没有兼容的密码套件。
向密钥库和信任库添加 RSA 密钥可解决此问题,而无需依赖旧密码套件。
hw12203:...src/test/resources alopresto
10s @ 12:43:08 $ keytool -genkey -keyalg RSA -alias localhost -keystore localhost-ks.jks -validity 360 -keysize 2048
Enter keystore password:
What is your first and last name?
[Unknown]: localhost
What is the name of your organizational unit?
[Unknown]: Apache NiFi
What is the name of your organization?
[Unknown]: Apache
What is the name of your City or Locality?
[Unknown]: Santa Monica
What is the name of your State or Province?
[Unknown]: CA
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=localhost, OU=Apache NiFi, O=Apache, L=Santa Monica, ST=CA, C=US correct?
[no]: yes
Enter key password for <localhost>
(RETURN if same as keystore password):
hw12203:...src/test/resources alopresto
23s @ 12:46:09 $ keytool -exportcert -alias localhost -file localhost.der -keystore localhost-ks.jks
Enter keystore password:
Certificate stored in file <localhost.der>
hw12203:...src/test/resources alopresto
2s @ 12:46:34 $ keytool -import -alias localhost -file localhost.der -keystore localhost-ts.jks
Enter keystore password:
Owner: CN=localhost, OU=Apache NiFi, O=Apache, L=Santa Monica, ST=CA, C=US
Issuer: CN=localhost, OU=Apache NiFi, O=Apache, L=Santa Monica, ST=CA, C=US
Serial number: 6f3e5921
Valid from: Tue Jan 05 12:46:04 PST 2016 until: Fri Dec 30 12:46:04 PST 2016
Certificate fingerprints:
MD5: 9F:CE:78:6D:18:0B:CF:7D:57:50:02:10:BA:98:27:62
SHA1: FA:70:D1:5C:BE:90:D3:CA:A0:3D:5E:67:62:D1:25:F6:31:2E:59:31
SHA256: A8:09:89:7C:19:6E:05:5B:CB:04:09:2C:30:5B:35:85:23:0F:C6:8A:12:00:4C:9F:39:5E:40:43:86:3E:FB:09
Signature algorithm name: SHA256withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: AB 88 BA FA F7 F5 AE 22 69 E4 B6 89 3D FB B0 61 ......."i...=..a
0010: 30 95 A3 27 0..'
]
]
Trust this certificate? [no]: yes
Certificate was added to keystore