sun jdk support
See original GitHub issueWhen I ran the encryption code with open jdk 1.8 it is all working fine. But when I am running with sun jdk jdk1.8.0_20, it is trowing following exception
Exception in thread "main" java.security.InvalidKeyException: Not an EC key: ECDH
at sun.security.ec.ECKeyFactory.checkKey(ECKeyFactory.java:121)
at sun.security.ec.ECKeyFactory.toECKey(ECKeyFactory.java:90)
at sun.security.ec.ECDHKeyAgreement.engineInit(ECDHKeyAgreement.java:67)
at javax.crypto.KeyAgreement.implInit(KeyAgreement.java:341)
at javax.crypto.KeyAgreement.chooseProvider(KeyAgreement.java:373)
at javax.crypto.KeyAgreement.init(KeyAgreement.java:465)
at javax.crypto.KeyAgreement.init(KeyAgreement.java:436)
at nl.martijndwars.webpush.HttpEce.deriveDH(HttpEce.java:117)
at nl.martijndwars.webpush.HttpEce.deriveKey(HttpEce.java:54)
at nl.martijndwars.webpush.HttpEce.encrypt(HttpEce.java:166)
at nl.martijndwars.webpush.PushService.encrypt(PushService.java:62)
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Oracle Java SE Support Roadmap
Oracle provides this Oracle Java SE Support Roadmap, to help you understand maintenance and support options and related timelines.
Read more >End of Service Life for Software Support (Sun Identity ...
Product Name Product Status Last Ship Date Phase 1(Full Supp...
Sun Java System Identity Manager 7.1.1 Post RR May 15, 2009 May 15, 2010
Sun...
Read more >FAQ - Sun Packages - Oracle
The classes in sun.* are present in the JDK to support Oracle's implementation of the Java platform: the sun.* classes are what make...
Read more >Supported Software and Environments (Sun Identity Manager ...
Supported Software and Environments. This section lists software and environments that are compatible with Identity product software: Operating Systems.
Read more >Platform Support and System Requirements (Sun Java ...
Sun Glass Fish Web Space Server (WSS) 10.0 Update 6 supports JDK 5 on Mac OS only, and not on Solaris, Linux, or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

After some hit and trial I am able to resolve it.
Issue: When I was working with JDK 1.8 and bcprov-jdk15on-164.jar which is the latest bouncy castle for JDK 1.5 - JDK 1.11, it was working awesome. But bcprov-jdk15on-164.jar doesn’t work for JDK 1.7.0_80 and getting “java.security.InvalidKeyException: Not an EC key: ECDH” error.
Solution: While working with JDK 1.7.0_80 please use bcprov-jdk15to18-164.jar provider which is for JDK 1.5 - JDK 1.8.
I came across this issue as well when I created a fat JAR (a.k.a. uber JAR, shadow JAR). The BouncyCastle JAR is signed and if you create a fat JAR the contents of the BouncyCastle JAR are extracted and put in the fat JAR which breaks the signature. I suspect something similar was happening to you.
When I realised this I updated the
build.gradleto exclude BouncyCastle from the fat JAR and add../../lib/bcprov-jdk15on-154.jarto the Class-Path definitionMANIFEST.MF. That way, when you run the generated fat JAR, it adds BouncyCastle to the classpath. Unfortunately, I had to commitlib/bcprov-jdk15on-154.jarinto git.In practice, developers will be using this project as a library and not as a fat JAR, so they will have to change their build to provide BouncyCastle at runtime. There are many ways to do this:
bcprov-jdk15on-154.jarin$JAVA_HOME/jre/lib/ext, like you suggested. The downside of this approach is that if you need to repeat this if you update your JRE.gradle.buildto add a Class-Path to theMANIFEST.MF). The downside is that you need to commitbcprov-jdk15on-154.jarinto git.I will update the README with instructions. Thanks for your investigation and feedback!