2016-07-29 172 views
1

我编写了一个测试代码(不是HTTPS)来测试带有JDK8的TLS。当测试代码运行,我用nmap的工具来扫描并得到结果如下:如何在不更改源代码的情况下禁用TLSv1?

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

我援引 “setEnabledProtocols” 在我的测试代码javax.net.ssl.SSLEngine中的类的方法,TLSv1.0可以完全禁用。 有没有更改代码禁用TLSv1.0的方法?例如通过配置文件。
我尝试了几种方法作为遵循,但没有人能达到预期的效果:(
1. -Djdk.tls.client.protocols = TLSv1.1,TLSv1.2工作
2. -Ddeployment.security.TLSv1 =假

这里是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) 

回答

1

你似乎是编写服务器,jdk.tls.client.protocols适用于客户,因此而得名;虽然略有不太明显,基本JavaSE的“部署”是指浏览器的or-WebStart是客户端的一个子集。

没有专门针对TLS(或HTTPS)服务器协议属性,但安全性能jdk.tls.disabledAlgorithms既适用于客户端和服务器(以及所有上下文类型也可以),并在你的链接页面表示可以JRE/lib/security/java.security进行设置。请务必保留现有限制(特别是从8u31开始删除SSLv3),同时添加您的限制。

+0

买者自负,'-D'将*不*为'jdk.tls工作.disabledAlgorithms',如你所说,它应该进入java.security'文件。 – kubanczyk

0

首先感谢您的回复。 如果修改JRE/lib/security/java.security,那将会产生全球影响。

这里是我的解决方案: 复制JRE/lib/security/java.security到一个新的文件,并添加TLSv1到jdk.tls.disabledAlgorithms
然后,启动JVM是这样的:
的Java -Djava.security.properties=./java.security罐子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 
相关问题