-
Notifications
You must be signed in to change notification settings - Fork 111
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
sun jdk support #5
Comments
Try adding the following code to your initialisation. This installs the BouncyCastle security provider:
|
I added it without which it's not even working |
Any update on this issue? I've added the code snippet to add the BouncyCastleProvider but I'm still receiving the same exception: |
Sorry, no update. I can spend some time on this next weekend, but since I'm not able to reproduce the problem it's very hard to debug. What is your setup (operating system, Java runtime, etc)? |
Thank you Martijn! I'm running on Mac, Java 1.8 in a Spring application. It's happening on the pushService.send(notification) call. |
If I recall correctly, Sun's implementation of Java Cryptography Extension (JCE), which is included in the JDK, does not support ECDH. That's the reason I added a dependency on BouncyCastle; they do provide the necessary encryption. From the stack trace I infer that it is using Sun's implementation instead of BouncyCastle's implementation. I cannot explain why this is happening. Could you try to give BouncyCastle provider highest priority? Instead of just calling
|
I did the same check and I get a similar result. It's not necessarily bad that it first tries Sun's implementation. In fact, that's what happens on my machine as well. While stepping through the code, the Could you try stepping through the code and see if something similar happens (or where it goes wrong)? |
Found out the issue was that the JCE could not authenticate the BouncyCastleProvider, even when explicitly adding the provider via The solution that worked for me can be found here: https://stackoverflow.com/a/17400821, which was to manually add the BouncyCastle jars to the directory: $JAVA_HOME/jre/lib/ext/. Those jars can just be downloaded from the BouncyCastle website: https://www.bouncycastle.org/latest_releases.html |
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 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:
I will update the README with instructions. Thanks for your investigation and feedback! |
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. |
Since there already is a dependency to BouncyCastle in Utils.java it doesn't add any more restrictions doing this, also this solves the following issue web-push-libs#5
When 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
The text was updated successfully, but these errors were encountered: