JDK 11.0.10 support for X25519 and X448 in TLS
Howdy,
With the release of JDK 11.0.10, I've begun to see the following exceptions in my logs:
Caused by: java.lang.ClassCastException: class org.bouncycastle.jcajce.provider.asymmetric.edec.BCXDHPublicKey cannot be cast to class java.security.interfaces.XECPublicKey (org.bouncycastle.jcajce.provider.asymmetric.edec.BCXDHPublicKey is in unnamed mod
ule of loader 'app'; java.security.interfaces.XECPublicKey is in module java.base of loader 'bootstrap')
at sun.security.ssl.XDHKeyExchange$XDHEPossession.<init>(XDHKeyExchange.java:108) ~[?:?]
at sun.security.ssl.NamedGroup$XDHFunctions.createPossession(NamedGroup.java:754) ~[?:?]
at sun.security.ssl.NamedGroup.createPossession(NamedGroup.java:394) ~[?:?]
at sun.security.ssl.SSLKeyExchange$T13KeyAgreement.createPossession(SSLKeyExchange.java:568) ~[?:?]
at sun.security.ssl.SSLKeyExchange.createPossessions(SSLKeyExchange.java:84) ~[?:?]
at sun.security.ssl.KeyShareExtension$CHKeyShareProducer.produce(KeyShareExtension.java:257) ~[?:?]
at sun.security.ssl.SSLExtension.produce(SSLExtension.java:563) ~[?:?]
at sun.security.ssl.SSLExtensions.produce(SSLExtensions.java:253) ~[?:?]
at sun.security.ssl.ClientHello$ClientHelloKickstartProducer.produce(ClientHello.java:650) ~[?:?]
at sun.security.ssl.SSLHandshake.kickstart(SSLHandshake.java:525) ~[?:?]
at sun.security.ssl.ClientHandshakeContext.kickstart(ClientHandshakeContext.java:107) ~[?:?]
at sun.security.ssl.TransportContext.kickstart(TransportContext.java:232) ~[?:?]
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:433) ~[?:?]
... 54 more
In this release support was added for ECC curves X25519 and X448 in TLS. This appears to not play nicely with BC 1.67. Searching through prior issues, it seems that there was a similar report for JDK 13 that was fixed in https://github.com/bcgit/bc-java/issues/620. Fortunately for those needing a workaround, the one presented there works for me by setting the following JVM arg:
jdk.tls.namedGroups="secp256r1, secp384r1, secp521r1, ffdhe2048, ffdhe3072, ffdhe4096, ffdhe6144, ffdhe8192"
Sorry if this is a duplicate, just looking to get visibility out there!
Going to go ahead and self-resolve as this appears fixed with https://github.com/ok3141/bc-java/commit/18c3bb7cb6f17b14402501623239433f3f06ae56