webpush-java icon indicating copy to clipboard operation
webpush-java copied to clipboard

Update HttpEce to use BC provider when calling KeyAgreement

Open frmans opened this issue 2 years ago • 1 comments

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 https://github.com/web-push-libs/webpush-java/issues/5

frmans avatar May 09 '23 13:05 frmans

This is useful patch. It helped me to reveal the problem under wildfly: https://issues.redhat.com/browse/WFLY-4576

java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
	at javax.crypto.JceSecurity.getInstance(JceSecurity.java:105)
	at javax.crypto.KeyAgreement.getInstance(KeyAgreement.java:230)
	at nl.martijndwars.webpush.HttpEce.extractDH(HttpEce.java:360)
...
Caused by: java.lang.SecurityException: Cannot verify jar:vfs:/content/runawfe.ear/lib/bcprov-debug-jdk18on-1.73.jar!/
	at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:448)
...
Caused by: java.security.PrivilegedActionException: java.util.zip.ZipException: zip file is empty
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:426)
	... 75 more
Caused by: java.util.zip.ZipException: zip file is empty
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:225)
	... 77 more
	Suppressed: java.nio.file.NoSuchFileException: /tmp/jar_cache2337284540188290599.tmp
		at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
		... 86 more

dofs197 avatar Jul 03 '23 07:07 dofs197