java.security.InvalidKeyException: Not an EC key: ECDH
See original GitHub issueI’m getting this error using the CLI send-notification 👍
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:346)
at javax.crypto.KeyAgreement.chooseProvider(KeyAgreement.java:378)
at javax.crypto.KeyAgreement.init(KeyAgreement.java:470)
at javax.crypto.KeyAgreement.init(KeyAgreement.java:441)
at webpush.HttpEce.extractDH(HttpEce.java:360)
at webpush.HttpEce.extractSecretAndContext(HttpEce.java:229)
at webpush.HttpEce.deriveKeyAndNonce(HttpEce.java:256)
at webpush.HttpEce.encrypt(HttpEce.java:70)
at webpush.PushService.encrypt(PushService.java:94)
at webpush.PushService.preparePost(PushService.java:179)
at webpush.PushService.sendAsync(PushService.java:150)
at webpush.PushService.send(PushService.java:132)
at webpush.PushService.send(PushService.java:136)
at webpush.cli.handlers.SendNotificationHandler.run(SendNotificationHandler.java:27)
at webpush.cli.Cli.main(Cli.java:43)
any idea what could cause this ? (I checked all parameters)
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
InvalidKeyException using ECPublicKey - Stack Overflow
I'm getting the following exception when i try to encrypt a byte array with a EC public key :
Read more >Bug ID: JDK-8261502 ECDHKeyAgreement
A DESCRIPTION OF THE PROBLEM : After updating from OpenJDK 13.0.2 to OpenJDK 15.0.2 our code that generates an ECDH key agreement fails...
Read more >ECDH - nimbus-jose-jwt 6.4 javadoc
InvalidKeyException ; 023import java.security. ... i.e. the consumer's public EC 144 * key on encryption, or the ephemeral public EC key 145 *...
Read more >KeyGenParameterSpec - Android Developers
Example: EC key for ECDH key agreement. This example illustrates how to generate an elliptic curve key pair, used to establish a shared...
Read more >src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java
else if (key instanceof ECPublicKey) { ECPublicKey ecKey ... should never occur throw new InvalidKeyException ("Key class not yet supported: " + key....
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
I have the same issue as OP. When I run the same code with same vapid locally, everything works (only once appeared exception mentioned in original post). When I run it on the server, this exception appears every time code tries to send notification. I think there could be issue with some incompatible overlapping dependencies, but I’ll have to do some further investigation.
I tried using openjdk 13 and the problem went away, but I didn’t understand why it throws an exception on jdk 17