-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java 13 Compatibility -- ClassCastException BCXDHPublicKey to XECPublicKey #620
Comments
I am also seeing this same problem now when not using the workaround noted in #589. |
Okay, I think this is finally working - we have a multi-release jar that seems to do the job. See https://www.bouncycastle.org/betas Let us know how it goes. |
Great! We're looking into how to test the beta. |
I was hitting this issue also with 1.64. I upgraded to the beta version now hitting this exception because the key type is XDHPublicKeyImpl.
key value: Caused by: javax.net.ssl.SSLHandshakeException: Could not generate secret |
How is the key being generated? |
The key is the peer public key and it was created using openssl below. The server is c++ with tls 1.3 that uses openssl and boost. openssl genpkey -out "${1}.key.pem" -outform PEM -algorithm ed25519 Note: This problem only happens when I move the BouncyCastleProvider preference up.
|
Actually, what I meant was how is the key been created in Java? The stack trace indicates a non BC key is being passed to the BC key agreement function. Although in this case it might be possible to work around, strictly speaking keys need to be used with the provider they are generated with. |
Some more debugging I realized that sslcontext was incorrect and that is why the peer keys got created with the default provider. I updated the sslcontext to also use BCJSSE as the provider and it works now. The down fall is that I am limited to TLSv1.2. Any updates on TLSv1.3 support? Thanks. |
We're working on it. Hoping for 1.66. |
When you have tls 1.3 beta support, I am more than willing to help tests. Thanks. |
This causes java.security.InvalidKeyException: cannot identify XDH private key on Java 11 or higher. See also - bcgit/bc-java#620 - bcgit/bc-java#589 - corretto/corretto-11#168 - https://bugs.openjdk.java.net/browse/JDK-8171279
This causes java.security.InvalidKeyException: cannot identify XDH private key on Java 11 or higher. See also - bcgit/bc-java#620 - bcgit/bc-java#589 - corretto/corretto-11#168 - https://bugs.openjdk.java.net/browse/JDK-8171279
As this causes org.jivesoftware.smack.SmackException$SmackWrappedException: javax.net.ssl.SSLHandshakeException: Could not generate secret org.jivesoftware.smack.AbstractXMPPConnection.setCurrentConnectionExceptionAndNotify(AbstractXMPPConnection.java:690) org.jivesoftware.smack.AbstractXMPPConnection.notifyConnectionError(AbstractXMPPConnection.java:994) org.jivesoftware.smack.tcp.XMPPTCPConnection.access$4100(XMPPTCPConnection.java:130) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1164) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936) java.lang.Thread.run(Thread.java:829) javax.net.ssl.SSLHandshakeException: Could not generate secret sun.security.ssl.KAKeyDerivation.t13DeriveKey(KAKeyDerivation.java:128) sun.security.ssl.KAKeyDerivation.deriveKey(KAKeyDerivation.java:63) sun.security.ssl.ServerHello$T13ServerHelloConsumer.consume(ServerHello.java:1256) sun.security.ssl.ServerHello$ServerHelloConsumer.onServerHello(ServerHello.java:990) sun.security.ssl.ServerHello$ServerHelloConsumer.consume(ServerHello.java:878) sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392) sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:443) sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:421) sun.security.ssl.TransportContext.dispatch(TransportContext.java:182) sun.security.ssl.SSLTransport.decode(SSLTransport.java:171) sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1418) sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1324) sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:440) sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:411) org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:730) org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1400(XMPPTCPConnection.java:130) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:987) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936) java.lang.Thread.run(Thread.java:829) java.security.InvalidKeyException: cannot identify XDH private key org.bouncycastle.jcajce.provider.asymmetric.edec.KeyAgreementSpi.engineDoPhase(Unknown Source) javax.crypto.KeyAgreement.doPhase(KeyAgreement.java:579) sun.security.ssl.KAKeyDerivation.t13DeriveKey(KAKeyDerivation.java:104) sun.security.ssl.KAKeyDerivation.deriveKey(KAKeyDerivation.java:63) sun.security.ssl.ServerHello$T13ServerHelloConsumer.consume(ServerHello.java:1256) sun.security.ssl.ServerHello$ServerHelloConsumer.onServerHello(ServerHello.java:990) sun.security.ssl.ServerHello$ServerHelloConsumer.consume(ServerHello.java:878) sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392) sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:443) sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:421) sun.security.ssl.TransportContext.dispatch(TransportContext.java:182) sun.security.ssl.SSLTransport.decode(SSLTransport.java:171) sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1418) sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1324) sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:440) sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:411) org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:730) org.jivesoftware.smack.tcp.XMPPTCPConnection.access$1400(XMPPTCPConnection.java:130) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:987) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$700(XMPPTCPConnection.java:913) org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:936) java.lang.Thread.run(Thread.java:829) See also bcgit/bc-java#620
In WildFly we updated our master branch to use 1.64 a couple weeks ago and I've noticed that since then our nightly job running our testsuite against JDK 13 is showing failures due to a CCE.
@spadou noted the same problem in a comment on #589 -- #589 (comment)
Apologies if this is a duplicate.
The stack trace:
The text was updated successfully, but these errors were encountered: