-
Notifications
You must be signed in to change notification settings - Fork 49
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
java.security.Provider contention #179
Comments
Hi @darranl I'm not sure individual So we can have initialized Providers statically, right now |
But it would likely require tweaking the parser code a bit for the |
Just finishing off some other tasks and will come and take a closer look - but +1 the actual Signature may not be re-usable but there may be some options to optimise how it is obtained to avoid hitting the synchronized code on each request. |
Ignore it please, we set a whitelist algorithm to a pre configured value, so it would be safe to pick up a statically initialized |
Hi @darranl I've looked through the Jose4j code, right now there is no way to bypass it. |
I have just been performing some profiling with SmallRye JWT within WildFly, the test has been pretty primitive hitting the server hard with simple HTTP requests containing a JWT token.
TBH most of the results look as I would expect, most of the time was spend in the operations relating to the handling of the signatures and as that is all that was happening to the requests that is as expected.
However one point of contention that comes up is syncrhonization within java.security.Provider.
Stack Trace Count Duration
java.security.Provider.getService(String, String) 166,894 6,144,694,265,281
sun.security.jca.ProviderList$ServiceList.tryGet(int) 156,244 5,798,524,329,105
sun.security.jca.ProviderList$ServiceList.access$200(ProviderList$ServiceList, int) 156,244 5,798,524,329,105
sun.security.jca.ProviderList$ServiceList$1.hasNext() 156,244 5,798,524,329,105
java.security.Signature.getInstance(String) 156,244 5,798,524,329,105
org.jose4j.jws.BaseSignatureAlgorithm.getSignature(ProviderContext) 156,244 5,798,524,329,105
org.jose4j.jws.BaseSignatureAlgorithm.verifySignature(byte[], Key, byte[], ProviderContext) 156,244 5,798,524,329,105
org.jose4j.jws.JsonWebSignature.verifySignature() 156,244 5,798,524,329,105
org.jose4j.jwt.consumer.JwtConsumer.processContext(JwtContext) 156,244 5,798,524,329,105
org.jose4j.jwt.consumer.JwtConsumer.process(String) 156,244 5,798,524,329,105
io.smallrye.jwt.auth.principal.DefaultJWTTokenParser.parse(String, JWTAuthContextInfo) 156,244 5,798,524,329,105
Just raising this issue as if there is any approach where the Signature can be cached without needing to keep hitting the factory it could bypass this contention.
The text was updated successfully, but these errors were encountered: