Removing signature from JAR file with JCE providers leads to SecurityException · Issue #3 · apache/tomcat-jakartaee-migration · GitHub
Skip to content
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

Removing signature from JAR file with JCE providers leads to SecurityException #3

Closed
smarkwal opened this issue Apr 14, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@smarkwal
Copy link

If this migration tool removes the cryptographic signature from a JAR file which contains JCE providers (e.g., Bouncy Castle), Java refuses to use these providers afterward:

java.lang.SecurityException: JCE cannot authenticate the provider BC
[...]
Caused by: java.util.jar.JarException: file:/tmp/[...]/bcprov-ext-jdk15on-1.65.jar has unsigned entries - org/bouncycastle/LICENSE.class

I see two possible solutions:

  1. If the classes in a JAR file do not have dependencies on Java EE classes, the JAR file is not touched by this migration tool. This means that the signature remains intact.
  2. If a JAR file contains JCE providers, it is not touched by this migration tool. Instead, a warning is printed.

I think that solution 1 is easier to implement, since it does not require special knowledge about JCE providers (or other features which require signed JAR files).

Bouncy Castle's main JAR file does not have dependencies on any Java EE classes. This means that both solutions would work for it.

@ebourg
Copy link
Member

ebourg commented Apr 14, 2020

Leaving JAR files unmodified if they don't reference any EE class sounds like the best solution to me. This will probably require buffering the files in memory.

@rmaucher
Copy link
Contributor

I think users should probably use scripting to exclude problem JARs from the migration.

Trying to do too much would lead to more problems, here a likely excessive memory use [there is the same problem with SB which wants some uncompressed JARs, also not doable without full load in memory]. This tool is IMO better if it stays simple.

@smarkwal
Copy link
Author

How about adding a command line option to exclude certain JAR files from getting migrated? It adds just a little bit of complexity in how to use the tool, but it has no impact on memory usage. And it is maybe useful in other scenarios as well.

@rmaucher
Copy link
Contributor

Yes, a resource filtering pattern or some kind could be a good add with plenty of uses.
Still copy out and in should work and would likely be easier for you to do with your JCE JAR.

@ebourg
Copy link
Member

ebourg commented Apr 15, 2020

Trying to do too much would lead to more problems, here a likely excessive memory use.

What is an excessive memory usage? A typical jar easily fits in the heap allocated by default to the JVM. This tool is mainly used at build time on beefy machines, I don't think the memory usage is really a concern.

How about adding a command line option to exclude certain JAR files from getting migrated?

Good idea, something like an --exclude option with a glob parameter that could be repeated many times.

@ebourg
Copy link
Member

ebourg commented Apr 15, 2020

Also bcprov*.jar could be excluded by default.

@ebourg ebourg added the bug Something isn't working label Apr 15, 2020
@ebourg ebourg changed the title Bug: Removing signature from JAR file with JCE providers leads to SecurityException Removing signature from JAR file with JCE providers leads to SecurityException Apr 15, 2020
DanielThomas pushed a commit to DanielThomas/tomcat-jakartaee-migration that referenced this issue Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants
@ebourg @rmaucher @smarkwal and others