You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bouncycastle 1.57 jar takes 5-10 seconds longer to load in Tomcat than 1.56 jar #205
We have noticed that the bouncycastle 1.57 jar takes 5-10 seconds longer to load in Tomcat (version 8.0.45) than the 1.56 jar did. Is this expected? I don't see anything in the 1.57 release notes that provides any obvious explanation.
Could you clarify if you mean just the BC provider or the new BCJSSE provider or both? Historically such startup delays have had to do either with generating DH parameters, or initialising RNGs (e.g. in VMs).
The default parameter sizes for DH and DSA are now 2048. If you have been relying on key pair generation without passing in parameters generated keys will now be larger.
I think that was increased from 1024, so perhaps you (or tomcat, or JSSE or ...) are now generating fresh 2048 bits DH parameters at startup, and BC looks for so-called safe primes, which is expensive.
We are using the following BC jars: bcprov-jdk15on-1.57.jar, bcpkix-jdk15on-1.57.jar, bc-fips-1.0.0.jar.
I did see that statement in the release notes, however we do not generate SSH keys at runtime in our servlet. We generate them at installation time. Also, the additional delay we see in Tomcat occurs before our servlet even starts executing. It occurs at jar-load-time, according to jstack.
Yes, that sounds a lot like parameter generation. Are you able to trigger a stack dump when it's half way through initialising? You'll probably find someone (not necessarily you) is generating a key pair using the BC provider.
I see the following stack trace frequently during Tomcat startup:
"localhost-startStop-1" #14 daemon prio=5 os_prio=0 tid=0x00007f92ac002000 nid=0x255a runnable [0x00007f92ec2a7000]
java.lang.Thread.State: RUNNABLE
at java.util.Vector.(Vector.java:148)
at sun.security.util.DerInputStream.readVector(DerInputStream.java:420)
at sun.security.util.DerInputStream.getSequence(DerInputStream.java:332)
at sun.security.provider.DSA.engineVerify(DSA.java:273)
at sun.security.provider.DSA.engineVerify(DSA.java:244)
at java.security.Signature$Delegate.engineVerify(Signature.java:1219)
at java.security.Signature.verify(Signature.java:652)
at sun.security.pkcs.SignerInfo.verify(SignerInfo.java:447)
at sun.security.pkcs.PKCS7.verify(PKCS7.java:579)
at sun.security.pkcs.PKCS7.verify(PKCS7.java:596)
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:292)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:268)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:316)
at java.util.jar.JarVerifier.update(JarVerifier.java:228)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
- locked <0x00000000fb8def30> (a sun.net.www.protocol.jar.URLJarFile)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:162)
at java.net.URL.openStream(URL.java:1045)
at org.apache.catalina.loader.WebappClassLoaderBase.findLoadedResource(WebappClassLoaderBase.java:2737)
at org.apache.catalina.loader.WebappClassLoaderBase.getResourceAsStream(WebappClassLoaderBase.java:1123)
at org.apache.catalina.startup.ContextConfig.populateJavaClassCache(ContextConfig.java:2207)
at org.apache.catalina.startup.ContextConfig.populateJavaClassCache(ContextConfig.java:2197)
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2102)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2054)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1999)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1969)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1923)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1166)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:783)
- locked <0x00000000e3101cc0> (a org.apache.catalina.startup.ContextConfig)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213)
- locked <0x00000000e3101950> (a org.apache.catalina.core.StandardContext)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
- locked <0x00000000e3101950> (a org.apache.catalina.core.StandardContext)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:621)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1835)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
It seems to be doing digital signature verification of the JAR files Tomcat is trying to use. Does that use the BC library underneath?
Regarding FIPS mode, when our servlet starts up we call CryptoServicesRegistrar.setApprovedOnlyMode and pass in either true or false depending on the setting of a global property that the user choses at installation time when he deploys our servlet+Tomcat. So during any given execution of our servlet, we are either using FIPS mode or non-FIPS mode, not a mixture of both.
Activity
peterdettman commentedon Aug 7, 2017
Could you clarify if you mean just the BC provider or the new BCJSSE provider or both? Historically such startup delays have had to do either with generating DH parameters, or initialising RNGs (e.g. in VMs).
peterdettman commentedon Aug 7, 2017
See this from 1.57 release notes:
I think that was increased from 1024, so perhaps you (or tomcat, or JSSE or ...) are now generating fresh 2048 bits DH parameters at startup, and BC looks for so-called safe primes, which is expensive.
Steven4321 commentedon Aug 7, 2017
We are using the following BC jars: bcprov-jdk15on-1.57.jar, bcpkix-jdk15on-1.57.jar, bc-fips-1.0.0.jar.
I did see that statement in the release notes, however we do not generate SSH keys at runtime in our servlet. We generate them at installation time. Also, the additional delay we see in Tomcat occurs before our servlet even starts executing. It occurs at jar-load-time, according to jstack.
dghbk commentedon Aug 8, 2017
Yes, that sounds a lot like parameter generation. Are you able to trigger a stack dump when it's half way through initialising? You'll probably find someone (not necessarily you) is generating a key pair using the BC provider.
Steven4321 commentedon Aug 8, 2017
I see the following stack trace frequently during Tomcat startup:
"localhost-startStop-1" #14 daemon prio=5 os_prio=0 tid=0x00007f92ac002000 nid=0x255a runnable [0x00007f92ec2a7000]
java.lang.Thread.State: RUNNABLE
at java.util.Vector.(Vector.java:148)
at sun.security.util.DerInputStream.readVector(DerInputStream.java:420)
at sun.security.util.DerInputStream.getSequence(DerInputStream.java:332)
at sun.security.provider.DSA.engineVerify(DSA.java:273)
at sun.security.provider.DSA.engineVerify(DSA.java:244)
at java.security.Signature$Delegate.engineVerify(Signature.java:1219)
at java.security.Signature.verify(Signature.java:652)
at sun.security.pkcs.SignerInfo.verify(SignerInfo.java:447)
at sun.security.pkcs.PKCS7.verify(PKCS7.java:579)
at sun.security.pkcs.PKCS7.verify(PKCS7.java:596)
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:292)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:268)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:316)
at java.util.jar.JarVerifier.update(JarVerifier.java:228)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
- locked <0x00000000fb8def30> (a sun.net.www.protocol.jar.URLJarFile)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:162)
at java.net.URL.openStream(URL.java:1045)
at org.apache.catalina.loader.WebappClassLoaderBase.findLoadedResource(WebappClassLoaderBase.java:2737)
at org.apache.catalina.loader.WebappClassLoaderBase.getResourceAsStream(WebappClassLoaderBase.java:1123)
at org.apache.catalina.startup.ContextConfig.populateJavaClassCache(ContextConfig.java:2207)
at org.apache.catalina.startup.ContextConfig.populateJavaClassCache(ContextConfig.java:2197)
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2102)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2054)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1999)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1969)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1923)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1166)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:783)
- locked <0x00000000e3101cc0> (a org.apache.catalina.startup.ContextConfig)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213)
- locked <0x00000000e3101950> (a org.apache.catalina.core.StandardContext)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
- locked <0x00000000e3101950> (a org.apache.catalina.core.StandardContext)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:621)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1835)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
It seems to be doing digital signature verification of the JAR files Tomcat is trying to use. Does that use the BC library underneath?
Regarding FIPS mode, when our servlet starts up we call CryptoServicesRegistrar.setApprovedOnlyMode and pass in either true or false depending on the setting of a global property that the user choses at installation time when he deploys our servlet+Tomcat. So during any given execution of our servlet, we are either using FIPS mode or non-FIPS mode, not a mixture of both.
Steven4321 commentedon Aug 25, 2017
We finally got around to removing the unnecessary jars and trying this again. It doesn't seem to help with the startup time however unfortunately.