TlsPremasterSecret SecretKeyFactory不可用

时间:2018-05-02 08:19:51

标签: java ssl sslhandshakeexception

我在握手期间收到此错误的https网址。如何添加特定的SecretKeyFactory?该错误必须与此特定网址的https设置相关,因为其他类似的网址我不会收到该错误。 我使用的是JDK 1.8.0_162

javax.net.ssl.SSLHandshakeException: Could not generate secret
        at sun.security.ssl.DHCrypt.getAgreedSecret(DHCrypt.java:219)
        at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1106)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1052)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:987)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:162)
        at de.martinm.tools.EBICS.EBICSKernel.fetchHPB(EBICSKernel.java:918)
        at de.martinm.tools.EBICS.EBICSKernel.doFetch(EBICSKernel.java:675)
        at de.martinm.tools.EBICS.EBICSKernel.checkBankKeys(EBICSKernel.java:2013)
        at de.martinm.tools.EBICS.MyIFPEBICS.process(MyIFPEBICS.java:126)
        at de.martinm.tools.EBICS.MyIFPEBICS.main(MyIFPEBICS.java:144)
Caused by: java.security.NoSuchAlgorithmException: TlsPremasterSecret SecretKeyFactory not available
        at javax.crypto.SecretKeyFactory.<init>(SecretKeyFactory.java:122)
        at javax.crypto.SecretKeyFactory.getInstance(SecretKeyFactory.java:160)
        at iaik.security.dh.DHKeyAgreement.engineGenerateSecret(Unknown Source)
        at javax.crypto.KeyAgreement.generateSecret(KeyAgreement.java:648)
        at sun.security.ssl.DHCrypt.getAgreedSecret(DHCrypt.java:217)
        ... 16 more
Exception in thread "main" java.lang.NullPointerException
        at de.martinm.tools.EBICS.EBICSKernel.doFetch(EBICSKernel.java:679)
        at de.martinm.tools.EBICS.EBICSKernel.checkBankKeys(EBICSKernel.java:2013)
        at de.martinm.tools.EBICS.MyIFPEBICS.process(MyIFPEBICS.java:126)
        at de.martinm.tools.EBICS.MyIFPEBICS.main(MyIFPEBICS.java:144)

1 个答案:

答案 0 :(得分:0)

异常的原因是我必须在

的代码中添加的IAIK提​​供程序
IAIK.addAsProvider(false);

此提供商随后混淆了https通信。 添加后

Security.removeProvider("IAIK");

添加使用IAIK的代码的结尾,不再发生异常