[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bouncycastle-crypto-dev
Subject:    Re: [dev-crypto] IllegalStateException Could not load [javax.crypto.spec.PBEKeySpec]
From:       "martijn.list" <martijn.list () gmail ! com>
Date:       2015-07-10 21:08:36
Message-ID: 55A03454.9040109 () gmail ! com
[Download RAW message or body]

On 07/10/2015 10:53 PM, Charles LaPierre wrote:
> Hello everyone, 
> 
> Well I have no idea why, but rebooting and reinitializing the
> Boot2Docker seemed to have fixed my problem.
> Thanks to anyone who was trying to figure this out with me.

Could it be that you redeployed your application on a running Tomcat?

Redeploying a war which uses BC can be problematic. See for example:

http://stackoverflow.com/questions/10379799/bouncycastle-cannot-load-when-i-redeploy-application


Kind regards,

Martijn Brinkers

> _______________________________
> 
> Charles LaPierre
> charlesl@benetech.org <mailto:charlesl@benetech.org>
> > On Jul 10, 2015, at 11:35 AM, Charles LaPierre <charlesl@benetech.org
> > <mailto:charlesl@benetech.org>> wrote:
> > 
> > Hello Crypto experts! 
> > I have been monitoring this list for the past year and never needed to
> > post until today (which I guess is good :)
> > 
> > I am encountering a very strange bug which I hope someone might be
> > able to shed some light on.
> > 
> > First let me start by saying that under Mac OS. X running Oracle Java
> > 1.8.0.40, the latest BC bcprov-jdk15on-152 with Apache Tomcat/8.0.20
> > everything works fine, the exact same code runs without exception.
> > 
> > But when trying to run this same code from an exploded WAR file in a
> > Docker (1.7.0) Container that is running Ubuntu 14.04.2 LTS with
> > Oracle JDK 1.8.0.45 and Tomcat 8, I get this
> > odd IllegalStateException Could not load
> > [javax.crypto.spec.PBEKeySpec] when trying to keyFactory.generateSecret.
> > 
> > char[] passPhras = "password".toCharArray();
> > SecretKeyFactory keyFactory =
> > SecretKeyFactory.getInstance(PBE_ALGORITHM, "BC");
> > PBEKeySpec keySpec = new PBEKeySpec(passPhrase);
> > 
> > (All the above code works fine, but when we make this next call, this
> > is where the exception is triggered.)
> > 
> > SecretKey key = keyFactory.generateSecret(keySpec);
> > 
> > Below is the runtime exception that is thrown:
> > 
> > 
> > I verified that in the docker
> > container /usr/lib/jvm/java-8-oracle/jre/lib/jce.jar  exists and that
> > javax/crypto/spec/PBEKeySpec.class exists inside this jce.jar. 
> > 
> > Any thoughts would be greatly welcomed!
> > 
> > Here are the tomcat logs.
> > Thanks
> > 
> > .   ____          _            __ _ _
> > /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
> > ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
> > \\/ <smb:///>  ___)| |_)| | | | | || (_| |  ) ) ) )
> > '  |____| .__|_| |_|_| |_\__, | / / / /
> > =========|_|==============|___/=/_/_/_/
> > > > Spring Boot ::        (v1.2.3.RELEASE)
> > 
> > 2015-07-10
> > 16:23:45.487  INFO 1 --- [st-startStop-22] o.s.boot.SpringApplication
> > > Starting application on 42843fdbdb11 with PID 1
> > (/usr/local/tomcat/webapps/ROOT/WEB-INF/lib/spring-boot-1.2.3.RELEASE.jar
> > started by tomcat in /usr/local)
> > 2015-07-10
> > 16:23:45.512  INFO 1 --- [st-startStop-22] \
> > ationConfigEmbeddedWebApplicationContext : Refreshing \
> > org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3d716b29:
> >  startup date [Fri Jul 10 16:23:45 UTC 2015]; root of context hierarchy
> > 2015-07-10
> > 16:23:46.206  INFO 1 --- [st-startStop-22] o.s.web.context.ContextLoader 
> > > Root WebApplicationContext: initialization completed in 694 ms
> > 2015-07-10
> > 16:23:46.461  INFO 1 --- [st-startStop-22] \
> > b.a.w.TomcatWebSocketContainerCustomizer : NonEmbeddedServletContainerFactory \
> > detected. Websockets support should be native so this normally is not a problem.
> > 2015-07-10
> > 16:23:46.851  INFO 1 --- [st-startStop-22] o.s.b.c.e.ServletRegistrationBean 
> > > Mapping servlet: 'dispatcherServlet' to [/]
> > 2015-07-10
> > 16:23:46.852  INFO 1 --- [st-startStop-22] \
> >                 o.s.b.c.embedded.FilterRegistrationBean  : Mapping
> > filter: 'errorPageFilter' to: [/*]
> > 2015-07-10
> > 16:23:46.852  INFO 1 --- [st-startStop-22] \
> >                 o.s.b.c.embedded.FilterRegistrationBean  : Mapping
> > filter: 'characterEncodingFilter' to: [/*]
> > 2015-07-10
> > 16:23:46.852  INFO 1 --- [st-startStop-22] \
> >                 o.s.b.c.embedded.FilterRegistrationBean  : Mapping
> > filter: 'hiddenHttpMethodFilter' to: [/*]
> > Static dir:/usr/local/tomcat/webapps/ROOT/WEB-INF/classes/static
> > 2015-07-10
> > 16:23:47.013  INFO 1 --- [st-startStop-22] \
> > s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice:
> > org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3d716b29:
> >  startup date [Fri Jul 10 16:23:45 UTC 2015]; root of context hierarchy
> > 2015-07-10
> > 16:23:47.068  INFO 1 --- [st-startStop-22] \
> > s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped \
> > "{[/final],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" \
> > onto public java.lang.String \
> > SAG.FinalPageController.directError(javax.servlet.http.HttpSession,org.springframework.ui.Model)
> >  2015-07-10
> > 16:23:47.069  INFO 1 --- [st-startStop-22] \
> > s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped \
> > "{[/obtainXFormPrevious],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}"
> >  onto public java.lang.String
> > SAG.ObtainXFormController.goBack(javax.servlet.http.HttpSession,org.springframework.ui.Model)
> >  throws java.lang.Exception
> > 2015-07-10
> > 16:23:47.070  INFO 1 --- [st-startStop-22] \
> > s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped \
> > "{[/obtainXFormNext],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}"
> >  onto public java.lang.String
> > SAG.ObtainXFormController.retrieveXForm(javax.servlet.http.HttpSession,org.springf \
> > ramework.web.multipart.MultipartFile,java.lang.String,org.springframework.ui.Model,SAG.AppConfiguration)
> >  2015-07-10
> > 16:23:47.099  INFO 1 --- [st-startStop-22] \
> > o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto \
> > handler of type [class \
> > org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2015-07-10
> > 16:23:47.099  INFO 1 --- [st-startStop-22] \
> > o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of \
> > type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
> > 2015-07-10
> > 16:23:47.134  INFO 1 --- [st-startStop-22] \
> > o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto \
> > handler of type [class \
> > org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2015-07-10
> > 16:23:47.319  INFO 1 --- [st-startStop-22] o.s.j.e.a.AnnotationMBeanExporter 
> > > Registering beans for JMX exposure on startup
> > 2015-07-10
> > 16:23:47.329  INFO 1 --- [st-startStop-22] o.s.boot.SpringApplication
> > > Started application in 2.05 seconds (JVM running for
> > 40526.733)
> > 10-Jul-2015 16:23:47.344 INFO [localhost-startStop-22]
> > org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
> > application archive /usr/local/tomcat/webapps/ROOT.war has finished in
> > 3,748 ms
> > 2015-07-10
> > 16:23:55.461  INFO 1 --- [r-8080-exec-189] o.s.web.servlet.DispatcherServlet 
> > > FrameworkServlet 'dispatcherServlet': initialization started
> > 2015-07-10
> > 16:23:55.480  INFO 1 --- [r-8080-exec-189] o.s.web.servlet.DispatcherServlet 
> > > FrameworkServlet 'dispatcherServlet': initialization completed
> > in 18 ms
> > Fri 07/10 16:24:05 UTC AES Key Length: 2147483647
> > Fri 07/10 16:24:05 UTC RNG: NativePRNG
> > Fri 07/10 16:24:05 UTC Limiting SSL cipher suites to:
> > [TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,
> > TLS_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
> > TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
> > TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
> > TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
> > TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256]
> > reading keypair:
> > /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/static/keys/sagKeyPair.dat
> > 10-Jul-2015 16:24:05.493 INFO [http-apr-8080-exec-187]
> > org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading
> > Illegal access: this web application instance has been stopped
> > already. Could not load [javax.crypto.spec.PBEKeySpec]. The following
> > stack trace is thrown for debugging purposes as well as to attempt to
> > terminate the thread which caused the illegal access.
> > java.lang.IllegalStateException: Illegal access: this web application
> > instance has been stopped already. Could not load
> > [javax.crypto.spec.PBEKeySpec]. The following stack trace is thrown
> > for debugging purposes as well as to attempt to terminate the thread
> > which caused the illegal access.
> > at
> > org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1327)
> >  at
> > org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1313)
> >  at
> > org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1196)
> >  at
> > org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
> >  at
> > org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEKeyFactory.engineGenerateSecret(Unknown
> >  Source)
> > at javax.crypto.SecretKeyFactory.generateSecret(SecretKeyFactory.java:330)
> > at
> > org.martus.common.crypto.MartusSecurity.pbeEncryptDecrypt(MartusSecurity.java:948)
> >  at
> > org.martus.common.crypto.MartusSecurity.pbeDecrypt(MartusSecurity.java:940)
> > at
> > org.martus.common.crypto.MartusSecurity.decryptKeyPair(MartusSecurity.java:930)
> > at
> > org.martus.common.crypto.MartusSecurity.readKeyPair(MartusSecurity.java:240)
> > at
> > org.martus.common.crypto.MartusCrypto.readKeyPair(MartusCrypto.java:142)
> > at
> > SAG.ObtainTokenController.getClientPublicKeyFromToken(ObtainTokenController.java:210)
> >  at SAG.ObtainTokenController.nextPage(ObtainTokenController.java:96)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> > at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> >  at java.lang.reflect.Method.invoke(Method.java:497)
> > at
> > org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
> >  at
> > org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
> >  at
> > org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
> >  at
> > org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
> >  at
> > org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
> >  at
> > org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
> >  …(more stace trace truncated due to:Your post bounced as it was too
> > large 57317>51200 (setting max_size in lists.dat)
> 


-- 
CipherMail email encryption

Open source email encryption gateway with support for S/MIME, OpenPGP
and PDF messaging.

https://www.ciphermail.com

Twitter: http://twitter.com/CipherMail


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic