Crucible setup error: Failed to setup JIRA integration
Asked by Alexander Farennikov:

I am on Step 3 of connecting Crucible to Jira and I keep getting this message:

**Errors:**

* Failed to setup JIRA integration: java.security.spec.InvalidKeySpecException: java.lang.ClassCastException: org.bouncycastle.asn1.DERInteger cannot be cast to org.bouncycastle.asn1.ASN1Sequence

In Crucible log I have this:

> 2013-11-25 18:54:31,217 ERROR - Failed to setup JIRA integration: java.security.spec.InvalidKeySpecException: java.lang.ClassCastException: org.bouncycastle.asn1.DERInteger cannot be cast to org.bouncycastle.asn1.ASN1Sequence
>
> com.atlassian.fisheye.jira.setup.JiraSetupException: Failed to setup JIRA integration: java.security.spec.InvalidKeySpecException: java.lang.ClassCastException: org.bouncycastle.asn1.DERInteger cannot be cast to org.bouncycastle.asn1.ASN1Sequence
>
> at com.atlassian.fisheye.jira.setup.JiraSetupServiceImpl.linkFishEyeToJIRA(JiraSetupServiceImpl.java:117)
>
> at com.cenqua.fisheye.web.admin.actions.setup.JiraConnectAction.tryConnectToJIRA(JiraConnectAction.java:91)
>
> at com.cenqua.fisheye.web.admin.actions.setup.JiraConnectAction.doView(JiraConnectAction.java:67)
>
> at sun.reflect.GeneratedMethodAccessor203.invoke(Unknown Source)
>
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:606)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:358)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:218)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:192)
>
> at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.atlassian.fisheye.xwork.SimpleConversionErrorInterceptor.intercept(SimpleConversionErrorInterceptor.java:64)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.opensymphony.xwork.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:186)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.cenqua.fisheye.web.admin.actions.setup.SetupInterceptor.intercept(SetupInterceptor.java:23)
>
> at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
>
> at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
>
> at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:274)
>
> at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:111)
>
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>
> at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1526)
>
> at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
>
> at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
>
> at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:25)
>
> at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
>
> at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
>
> at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
>
> at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
>
> at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
>
> at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
>
> at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.atlassian.crucible.filters.CrucibleFilter.doFilter(CrucibleFilter.java:146)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.cenqua.fisheye.web.filters.TotalityFilter.doFilter(TotalityFilter.java:293)
>
> at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
>
> at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:98)
>
> at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
>
> at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
>
> at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
>
> at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:55)
>
> at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
>
> at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
>
> at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
>
> at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:82)
>
> at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:256)
>
> at com.cenqua.fisheye.web.filters.CustomIncludableGzipFilter.doFilter(CustomIncludableGzipFilter.java:27)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.cenqua.fisheye.web.filters.ProductInfoFilter.doFilter(ProductInfoFilter.java:44)
>
> at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
>
> at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
>
> at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
>
> at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.cenqua.fisheye.web.filters.UpfrontFilter.doFilter(UpfrontFilter.java:59)
>
> at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
>
> at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at com.atlassian.fecru.profiling.ProfilingServletFilter.doFilter(ProfilingServletFilter.java:74)
>
> at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
>
> at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
>
> at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1502)
>
> at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
>
> at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>
> at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
>
> at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>
> at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
>
> at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
>
> at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>
> at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
>
> at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>
> at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
>
> at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
>
> at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>
> at org.eclipse.jetty.server.Server.handle(Server.java:368)
>
> at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
>
> at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953)
>
> at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014)
>
> at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
>
> at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
>
> at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>
> at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
>
> at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
>
> at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>
> at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>
> at java.lang.Thread.run(Thread.java:744)
>
> Caused by: java.lang.RuntimeException: java.security.spec.InvalidKeySpecException: java.lang.ClassCastException: org.bouncycastle.asn1.DERInteger cannot be cast to org.bouncycastle.asn1.ASN1Sequence
>
> at com.atlassian.security.auth.trustedapps.ListApplicationRetriever.getApplicationProtocolV0(ListApplicationRetriever.java:89)
>
> at com.atlassian.security.auth.trustedapps.ListApplicationRetriever.getApplicationProtocolV1(ListApplicationRetriever.java:48)
>
> at com.atlassian.security.auth.trustedapps.ListApplicationRetriever.getApplication(ListApplicationRetriever.java:42)
>
> at com.atlassian.security.auth.trustedapps.ReaderApplicationRetriever.getApplication(ReaderApplicationRetriever.java:27)
>
> at com.atlassian.security.auth.trustedapps.URLApplicationRetriever.getApplication(URLApplicationRetriever.java:41)
>
> at com.atlassian.security.auth.trustedapps.BaseEncryptionProvider.getApplicationCertificate(BaseEncryptionProvider.java:12)
>
> at com.atlassian.fisheye.trustedapplications.DefaultFisheyeTrustedApplicationsManager.getApplicationCertificate(DefaultFisheyeTrustedApplicationsManager.java:61)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:606)
>
> at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:129)
>
> at com.sun.proxy.$Proxy124.getApplicationCertificate(Unknown Source)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:606)
>
> at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:154)
>
> at com.sun.proxy.$Proxy124.getApplicationCertificate(Unknown Source)
>
> at com.atlassian.applinks.core.auth.trusted.TrustConfigurator.getApplicationCertificate(TrustConfigurator.java:65)
>
> at com.atlassian.applinks.core.auth.trusted.TrustConfigurator.issueInboundTrust(TrustConfigurator.java:76)
>
> at com.atlassian.applinks.core.auth.trusted.TrustedAppsAuthenticationProviderPluginModule.enable(TrustedAppsAuthenticationProviderPluginModule.java:141)
>
> at com.atlassian.applinks.core.auth.AuthenticationConfigurator.configureAuthenticationForApplicationLink(AuthenticationConfigurator.java:70)
>
> at com.atlassian.applinks.core.DefaultApplicationLinkService.configureAuthenticationForApplicationLink(DefaultApplicationLinkService.java:652)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:606)
>
> at com.atlassian.applinks.host.OsgiServiceProxyFactory$DynamicServiceInvocationHandler.invoke(OsgiServiceProxyFactory.java:111)
>
> at com.sun.proxy.$Proxy49.configureAuthenticationForApplicationLink(Unknown Source)
>
> at com.atlassian.fisheye.jira.setup.JiraSetupServiceImpl.authenticateApplicationLink(JiraSetupServiceImpl.java:228)
>
> at com.atlassian.fisheye.jira.setup.JiraSetupServiceImpl.linkFishEyeToJIRA(JiraSetupServiceImpl.java:92)
>
> ... 111 more
>
> Caused by: java.security.spec.InvalidKeySpecException: java.lang.ClassCastException: org.bouncycastle.asn1.DERInteger cannot be cast to org.bouncycastle.asn1.ASN1Sequence
>
> at org.bouncycastle.jce.provider.JDKKeyFactory$RSA.engineGeneratePublic(Unknown Source)
>
> at java.security.KeyFactory.generatePublic(KeyFactory.java:328)
>
> at com.atlassian.security.auth.trustedapps.BouncyCastleEncryptionProvider.toPublicKey(BouncyCastleEncryptionProvider.java:80)
>
> at com.atlassian.security.auth.trustedapps.ListApplicationRetriever.getApplicationProtocolV0(ListApplicationRetriever.java:84)
>
> ... 142 more


Answers:
author: Jeff Thomas
body: I believe you're running into [this](https://confluence.atlassian.com/display/FISHKB/Error+Setting+Application+Link+to+JIRA+OnDemand), where JIRA OnDemand can only connect to services on port 80 or 443.

You'll need to [configure your Crucible instance](https://confluence.atlassian.com/display/FISHEYE/Configuring+the+FishEye+web+server) so that it uses either port 80 or 443.


author: Alexander Farennikov
body: Thanks Jeff. But how unintuitive this is. They tell you to run it as "crucible" user without priveledged permissions, under higher port, and running as crucible on 80 or 443 is not even possible unless I run it as root. But yes, when I changed port to 80 and run it as root, it worked.


author: Jeff Thomas
body: Do you have Crucible or JIRA running on a port other than 80 or 443?


author: Alexander Farennikov
body: Jira is hosted, so it's default port. Crucible is :8060