2016-07-29 158 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 
相關問題