我编写了一个测试代码(不是HTTPS)来测试使用JDK8的TLS。当测试代码运行时,我使用nmap工具扫描并获得如下结果:
D:\softwares\nmap-7.12>nmap -p xxxx --script=ssl* x.x.x.x --unprivileged
Starting Nmap 7.12 ( https://nmap.org ) at 2016-07-26 15:33 °?′óà????÷2?±ê×?ê±??
Nmap scan report for x.x.x.x
Host is up (1.0s latency).
PORT STATE SERVICE
xxxx/tcp open unknown
| ssl-enum-ciphers:
| TLSv1.0:
| ciphers:
| TLS_RSA_WITH_AES_128_CBC_SHA (rsa 2048) -A
| compressors:
| NULL
| cipher preference: indeterminate
| cipher preference error: Too few ciphers supported
| TLSv1.1:
| ciphers:
| TLS_RSA_WITH_AES_128_CBC_SHA (rsa 2048) -A
| compressors:
| NULL
| cipher preference: indeterminate
| cipher preference error: Too few ciphers supported
| TLSv1.2:
| ciphers:
| TLS_RSA_WITH_AES_128_CBC_SHA (rsa 2048) -A
| compressors:
| NULL
| cipher preference: indeterminate
| cipher preference error: Too few ciphers supported
|_ least strength: A
MAC Address: xx:xx:xx:xx:xx:xx
Nmap done: 1 IP address (1 host up) scanned in 3.88 seconds
D:\softwares\nmap-7.12>
JDK8默认启用TLSv1.0,但我想禁用它。
Protocols
The SunJSSE provider supports the following protocol parameters:
Protocol Enabled by Default for Client Enabled by Default for Server
SSLv3 No(Unavailable Footnote 2) No(Unavailable Footnote 2)
TLSv1 Yes Yes
TLSv1.1 Yes Yes
TLSv1.2 Yes Yes
https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SunJSSE_Protocols
我在我的测试代码上调用了javax.net.ssl.SSLEngine类的“setEnabledProtocols”方法,可以完全禁用TLSv1.0。
有没有办法在没有更改代码的情况下禁用TLSv1.0?例如通过配置文件
我尝试了几种方法如下,但没有人能达到预期的效果:(
1. -Djdk.tls.client.protocols = TLSv1.1,TLSv1.2
2. -Ddeployment.security.TLSv1 = false
这是java版本:
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
答案 0 :(得分:1)
您似乎正在编写服务器,jdk.tls.client.protocols
适用于客户端,因此名称;虽然稍微不那么明显,但在基本的JavaSE'部署'表示浏览器或WebStart,它是客户端的子集。
没有专门针对TLS(或HTTPS)服务器协议的属性,但安全属性jdk.tls.disabledAlgorithms
同时适用于客户端和服务器(以及所有上下文类型),并且可以在JRE/lib/security/java.security
中设置为在您链接的页面中说明。确保在添加您的限制时保留现有限制(尤其是从8u31开始删除SSLv3)。
答案 1 :(得分:0)
首先感谢您的回复。
如果修改JRE/lib/security/java.security
,那将产生全球影响。
这是我的解决方案:
将JRE/lib/security/java.security
复制到新文件,然后将TLSv1添加到jdk.tls.disabledAlgorithms
然后,像这样启动JVM:
java -Djava.security.properties=./java.security
-jar xxxxx
以下是JRE/lib/security/java.security
的摘要:
#
# This is the "master security properties file".
#
# An alternate java.security properties file may be specified
# from the command line via the system property
#
# -Djava.security.properties=<URL>
#
# This properties file appends to the master security properties file.
# If both properties files specify values for the same key, the value
# from the command-line properties file is selected, as it is the last
# one loaded.
#
# Also, if you specify
#
# -Djava.security.properties==<URL> (2 equals),
#
#
# Determines whether this properties file can be appended to
# or overridden on the command line via -Djava.security.properties
#
security.overridePropertiesFile=true