如何配置本地 Jetty ssl 以避免弱 phermeral DH 密钥错误?
How to config local Jetty ssl to avoid weak phermeral DH key error?
我正在使用 keytool 生成密钥库以将本地开发码头配置为 运行 ssl
keytool.exe -keystore jetty.keystore -alias jetty -genkey -keyalg RSA -sigalg SHA256withRSA
码头配置:
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Arg>
<New class="org.eclipse.jetty.http.ssl.SslContextFactory">
<Set name="keyStore">jetty/jetty.keystore</Set>
<Set name="keyStorePassword">jetty6</Set>
<Set name="keyManagerPassword">jetty6</Set>
<Set name="trustStore">jetty/jetty.keystore</Set>
<Set name="trustStorePassword">jetty6</Set>
</New>
</Arg>
<Set name="port">8443</Set>
<Set name="maxIdleTime">30000</Set>
</New>
</Arg>
</Call>
直到最近它在 Firefox Aurora 和 Chrome Canary 等新浏览器中工作正常,它拒绝(在 Firefox 的情况下):
An error occurred during a connection to localhost:8443. SSL received
a weak ephemeral Diffie-Hellman key in Server Key Exchange handshake
message. (Error code: ssl_error_weak_server_ephemeral_dh_key)
无法手动接受。那么,我应该重新生成一个更强的密钥吗?或者是jetty中的配置?
对jetty了解不多,但看来你找错人了。
firefox 抱怨的不是服务器密钥,而是用于建立连接的(临时)临时 DH 密钥。您需要配置码头可能使用的 SSL/TLS 加密。查看选择不同的密码套件。
这适用于 OpenJDK 7,因为上面调用 setIncludeCipherSuites () 的代码不允许任何连接
sslContextFactory.setExcludeCipherSuites("TLS_DHE.*", "TLS_EDH.*");
sslContextFactory.setExcludeProtocols("SSLv3");
sslContextFactory.setRenegotiationAllowed(false);
接受的答案并没有为我解决这个问题(Jetty 9.2,Java 7),但是这个解决了:
<Set name="ExcludeCipherSuites">
<Array type="String">
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
<Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
<Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<!-- Disable cipher suites with Diffie-Hellman key exchange to prevent Logjam attack
and avoid the ssl_error_weak_server_ephemeral_dh_key error in recent browsers -->
<Item>SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA</Item>
<Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA256</Item>
<Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA256</Item>
<Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA</Item>
<Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA</Item>
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA256</Item>
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA256</Item>
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA</Item>
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA</Item>
</Array>
</Set>
<!-- setting required for preventing Poodle attack, see -->
<Set name="ExcludeProtocols">
<Array type="java.lang.String">
<Item>SSLv3</Item>
</Array>
</Set>
UnSandpiper 解决方案的嵌入式 Jetty 代码:
sslContextFactory.setExcludeCipherSuites(
"SSL_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_DSS_WITH_DES_CBC_SHA",
"SSL_RSA_EXPORT_WITH_RC4_40_MD5",
"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
// Disable cipher suites with Diffie-Hellman key exchange to prevent Logjam attack
//and avoid the ssl_error_weak_server_ephemeral_dh_key error in recent browsers
"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
"SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
"SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
"TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
"TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
"TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
"TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
"TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
"TLS_DHE_DSS_WITH_AES_128_CBC_SHA");
// Setting required for preventing Poodle attack,
// see
sslContextFactory.setExcludeProtocols("SSLv3");
我正在使用 keytool 生成密钥库以将本地开发码头配置为 运行 ssl
keytool.exe -keystore jetty.keystore -alias jetty -genkey -keyalg RSA -sigalg SHA256withRSA
码头配置:
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Arg>
<New class="org.eclipse.jetty.http.ssl.SslContextFactory">
<Set name="keyStore">jetty/jetty.keystore</Set>
<Set name="keyStorePassword">jetty6</Set>
<Set name="keyManagerPassword">jetty6</Set>
<Set name="trustStore">jetty/jetty.keystore</Set>
<Set name="trustStorePassword">jetty6</Set>
</New>
</Arg>
<Set name="port">8443</Set>
<Set name="maxIdleTime">30000</Set>
</New>
</Arg>
</Call>
直到最近它在 Firefox Aurora 和 Chrome Canary 等新浏览器中工作正常,它拒绝(在 Firefox 的情况下):
An error occurred during a connection to localhost:8443. SSL received a weak ephemeral Diffie-Hellman key in Server Key Exchange handshake message. (Error code: ssl_error_weak_server_ephemeral_dh_key)
无法手动接受。那么,我应该重新生成一个更强的密钥吗?或者是jetty中的配置?
对jetty了解不多,但看来你找错人了。
firefox 抱怨的不是服务器密钥,而是用于建立连接的(临时)临时 DH 密钥。您需要配置码头可能使用的 SSL/TLS 加密。查看选择不同的密码套件。
这适用于 OpenJDK 7,因为上面调用 setIncludeCipherSuites () 的代码不允许任何连接
sslContextFactory.setExcludeCipherSuites("TLS_DHE.*", "TLS_EDH.*");
sslContextFactory.setExcludeProtocols("SSLv3");
sslContextFactory.setRenegotiationAllowed(false);
接受的答案并没有为我解决这个问题(Jetty 9.2,Java 7),但是这个解决了:
<Set name="ExcludeCipherSuites">
<Array type="String">
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
<Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
<Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
<!-- Disable cipher suites with Diffie-Hellman key exchange to prevent Logjam attack
and avoid the ssl_error_weak_server_ephemeral_dh_key error in recent browsers -->
<Item>SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA</Item>
<Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA256</Item>
<Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA256</Item>
<Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA</Item>
<Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA</Item>
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA256</Item>
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA256</Item>
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA</Item>
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA</Item>
</Array>
</Set>
<!-- setting required for preventing Poodle attack, see -->
<Set name="ExcludeProtocols">
<Array type="java.lang.String">
<Item>SSLv3</Item>
</Array>
</Set>
UnSandpiper 解决方案的嵌入式 Jetty 代码:
sslContextFactory.setExcludeCipherSuites(
"SSL_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_DSS_WITH_DES_CBC_SHA",
"SSL_RSA_EXPORT_WITH_RC4_40_MD5",
"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
// Disable cipher suites with Diffie-Hellman key exchange to prevent Logjam attack
//and avoid the ssl_error_weak_server_ephemeral_dh_key error in recent browsers
"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
"SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
"SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
"TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
"TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
"TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
"TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
"TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
"TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
"TLS_DHE_DSS_WITH_AES_128_CBC_SHA");
// Setting required for preventing Poodle attack,
// see
sslContextFactory.setExcludeProtocols("SSLv3");