无法在java 6中生成DH密钥对

时间:2016-11-10 20:40:26

标签: java ssl https

我正在尝试用https调用WS,我收到了这个错误:

Caused by: java.lang.RuntimeException: Could not generate DH keypair
    at sun.security.ssl.DHCrypt.<init>(Unknown Source)
    at sun.security.ssl.ClientHandshaker.serverKeyExchange(Unknown Source)
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
    at sun.security.ssl.Handshaker.processLoop(Unknown Source)
    at sun.security.ssl.Handshaker.process_record(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source
)
        ... 22 common frames omitted
Caused by: java.security.InvalidAlgorithmParameterException: Prime size must be
multiple of 64, and can only range from 512 to 1024 (inclusive)
        at com.sun.crypto.provider.DHKeyPairGenerator.initialize(DHKeyPairGenera
tor.java:120)
        at java.security.KeyPairGenerator$Delegate.initialize(Unknown Source)
        ... 29 common frames omitted

在java 7中我已经解决了 jdk.tls.disabledAlgorithms = DHE,ECDHE 在java安全性中, 但我必须使用java 6(然后我不确定禁用DH是个好主意;是否通过这种方式确保连接安全?)

我尝试过使用BouncyCastleProvider,我又收到了另一个错误:

Caused by: java.lang.RuntimeException: javax.net.ssl.SSLException: 

java.lang.Arr
ayIndexOutOfBoundsException: 64
        at net.unicon.Test.run(Test.java:61)
        at org.springframework.boot.SpringApplication.callRunner(SpringApplicati
on.java:798)
        ... 14 common frames omitted
Caused by: javax.net.ssl.SSLException: java.lang.ArrayIndexOutOfBoundsException:
 64
        at sun.security.ssl.Alerts.getSSLException(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.handleException(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect
(Unknown Source)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
urce)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unkn
own Source)
        at net.unicon.Test.run(Test.java:41)
        ... 15 common frames omitted
Caused by: java.lang.ArrayIndexOutOfBoundsException: 64
        at com.sun.crypto.provider.TlsPrfGenerator.expand(TlsPrfGenerator.java:2
75)
        at com.sun.crypto.provider.TlsPrfGenerator.doTLS10PRF(TlsPrfGenerator.ja
va:247)
        at com.sun.crypto.provider.TlsPrfGenerator.doTLS10PRF(TlsPrfGenerator.ja
va:219)
        at com.sun.crypto.provider.TlsMasterSecretGenerator.engineGenerateKey(Tl
sMasterSecretGenerator.java:108)
        at javax.crypto.KeyGenerator.generateKey(KeyGenerator.java:530)
        at sun.security.ssl.Handshaker.calculateMasterSecret(Unknown Source)
        at sun.security.ssl.Handshaker.calculateKeys(Unknown Source)
        at sun.security.ssl.ClientHandshaker.serverHelloDone(Unknown Source)
        at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
        at sun.security.ssl.Handshaker.processLoop(Unknown Source)
        at sun.security.ssl.Handshaker.process_record(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source
)
        ... 22 common frames omitted

0 个答案:

没有答案