<div dir="ltr">Responses inline<br><br>On 17 May 2016 at 16:16, Amit Joshi &lt;<a href="mailto:amit.joshi@markit.com">amit.joshi@markit.com</a>&gt; wrote:<br>&gt; Hello,<br>&gt;<br>&gt;  <br>&gt;<br>&gt; I have been following the information in the blog post:<br>&gt; <a href="http://www.apiman.io/blog/gateway/security/mutual-auth/ssl/mtls/1.2.x/2016/01/22/mtls-mutual-auth-redux.html">http://www.apiman.io/blog/gateway/security/mutual-auth/ssl/mtls/1.2.x/2016/01/22/mtls-mutual-auth-redux.html</a><br>&gt; but has a tough time. I had a simple Java test program that worked against<br>&gt; the Api with setting the has a trust store etc. using system properties:<br>&gt;<br>&gt;  <br>&gt;<br>&gt;         System.setProperty(&quot;javax.net.ssl.trustStore&quot;,<br>&gt; System.getProperty(&quot;truststore.path&quot;));<br>&gt;<br>&gt;         System.setProperty(&quot;javax.net.ssl.trustStorePassword&quot;,<br>&gt; System.getProperty(&quot;keystore.password&quot;));<br>&gt;<br>&gt;         System.setProperty(&quot;javax.net.ssl.keyStore&quot;,<br>&gt; System.getProperty(&quot;keystore.path&quot;));<br>&gt;<br>&gt;         System.setProperty(&quot;javax.net.ssl.keyStorePassword&quot;,<br>&gt; System.getProperty(&quot;keystore.password&quot;));<br>&gt;<br>&gt;         System.setProperty(&quot;javax.net.ssl.keyStoreType&quot;,<br>&gt; System.getProperty(&quot;keystore.type&quot;));<br>&gt;<br>&gt;  <br>&gt;<br>&gt; However, when I try to do the same , but using APIMan (and setting the<br>&gt; properties in the apiman.properties file) to gateway the API it fails as<br>&gt; below. I tried setting the –Djavax.net.debug.all  (as suggested in the<br>&gt; article) which gives a lot more in the logs but all I could see that looked<br>&gt; relevant: “Warning: no suitable certificate found - continuing without<br>&gt; client authentication” which made no sense since I have the correct cert and<br>&gt; it works with the test program.<br>&gt;<br>&gt; I finally figured out the issue – the MTLS setup does not allow you to pass<br>&gt; in the keyStoreType and my keystore was PKCS12 and not JKS.  <br>&gt;<br>&gt;  <br>&gt;<br>&gt; Couple of suggestions as a result:<br>&gt;<br>&gt; ·         Add the ability to set the keyStoreType so we won’t have to<br>&gt; convert them<br><br>That shouldn&#39;t be too hard <a href="https://issues.jboss.org/browse/APIMAN-1154">https://issues.jboss.org/browse/APIMAN-1154</a><br><br>&gt;<br>&gt; ·         Also the stacktrace gets truncated in the output (see below) and<br>&gt; its very difficult to diagnose what the problem is – something I think would<br>&gt; have been minutes if I could have seen the message about not being able to<br>&gt; load the keystore took hours.<br><br>I don&#39;t think it&#39;s truncated, it&#39;s just that the formatting might be difficult to read. I agree, though - we need to do something a bit nicer for humans in this area.<div><br></div><div>echo -e &quot;&lt;stacktrace&gt;&quot; can be a workaround for the moment.<br><br>From the docs:<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Note the presence of lines containing the characters &quot;...&quot;. These lines indicate that the remainder of the stack trace for this exception matches the indicated number of frames from the bottom of the stack trace of the exception that was caused by this exception (the &quot;enclosing&quot; exception). This shorthand can greatly reduce the length of the output in the common case where a wrapped exception is thrown from same method as the &quot;causative exception&quot; is caught. The above example was produced by running the program:</blockquote><br><br>&gt;<br>&gt; ·         Also I want to be able to automatically use different keystores<br>&gt; based on the api or logged-in user or url etc. My thought was to extend the<br>&gt; HttpConnectorFactory and override the TlsOptions. However the class has all<br>&gt; the properties private with no getters/setters and so it is difficult to do<br>&gt; so that. This means I have to pretty much make a copy of the class instead<br>&gt; of just a custom extension . Would be good if the class had public or at<br>&gt; least protected getters/setters there so I could override the keystore based<br>&gt; on some rules..</div><div><br></div><div>Unfortunately this isn&#39;t possible yet, but if you wouldn&#39;t mind, could you file a JIRA with your requirements (as above, plus any other bits you can think of). That will help guide us, as we&#39;re aware this is an area that might be of interest to some. It may be possible to do something clever in combination with Keycloak - but it&#39;ll require a bit more integration.</div><div><br>&gt;<br>&gt;  <br>&gt;<br>&gt; Results when running against apiman but with a pkcs12 keystore:<br>&gt;<br>&gt; Using the Advanced Rest Client app for Chrome. I see the following as a<br>&gt; response<br>&gt;<br>&gt; X-Gateway-Error: Not connected.<br>&gt;<br>&gt; 500  Internal Server Error<br>&gt;<br>&gt; And the response looks as follows. Note that the message is generic “Not<br>&gt; connected” and the stack trace is missing any information about why the<br>&gt; connection failed.</div><div><br></div><div>I&#39;ve already got a JIRA for this (<a href="https://issues.jboss.org/browse/APIMAN-690">https://issues.jboss.org/browse/APIMAN-690</a>), but it can be a pain sometimes because the underlying system tends to return pretty generic errors - I&#39;ll see what I can do to improve the situation. Thanks for bringing it up, it&#39;s certainly valid.</div><div><br>&gt;<br>&gt;  <br>&gt;<br>&gt; {<br>&gt;<br>&gt;   &quot;responseCode&quot;: 500,<br>&gt;<br>&gt;   &quot;message&quot;: &quot;Not connected.&quot;,<br>&gt;<br>&gt;   &quot;trace&quot;: &quot;io.apiman.gateway.engine.beans.exceptions.ConnectorException:<br>&gt; Not connected.\n\tat<br>&gt; io.apiman.gateway.platforms.servlet.connectors.HttpApiConnection.write(HttpApiConnection.java:332)\n\tat<br>&gt; io.apiman.gateway.engine.impl.ApiRequestExecutorImpl.lambda$null$1(ApiRequestExecutorImpl.java:234)\n\tat<br>&gt; io.apiman.gateway.engine.io.AbstractStream.handleBody(AbstractStream.java:107)\n\tat<br>&gt; io.apiman.gateway.engine.policy.Chain.write(Chain.java:181)\n\tat<br>&gt; io.apiman.gateway.engine.impl.ApiRequestExecutorImpl$1.write(ApiRequestExecutorImpl.java:525)\n\tat<br>&gt; io.apiman.gateway.platforms.servlet.GatewayServlet$2.handle(GatewayServlet.java:169)\n\tat<br>&gt; io.apiman.gateway.platforms.servlet.GatewayServlet$2.handle(GatewayServlet.java:161)\n\tat<br>&gt; io.apiman.gateway.engine.impl.ApiRequestExecutorImpl.handleStream(ApiRequestExecutorImpl.java:517)\n\tat<br>&gt; io.apiman.gateway.engine.impl.ApiRequestExecutorImpl.lambda$null$3(ApiRequestExecutorImpl.java:243)\n\tat<br>&gt; io.apiman.gateway.engine.policy.Chain.handleHead(Chain.java:211)\n\tat<br>&gt; io.apiman.gateway.engine.policy.Chain.doApply(Chain.java:150)\n\tat<br>&gt; io.apiman.gateway.engine.impl.ApiRequestExecutorImpl.lambda$execute$4(ApiRequestExecutorImpl.java:246)\n\tat<br>&gt; io.apiman.gateway.engine.impl.ApiRequestExecutorImpl.loadPolicies(ApiRequestExecutorImpl.java:419)\n\tat<br>&gt; io.apiman.gateway.engine.impl.ApiRequestExecutorImpl.lambda$execute$5(ApiRequestExecutorImpl.java:269)\n\tat<br>&gt; io.apiman.gateway.engine.impl.SecureRegistryWrapper$1.handle(SecureRegistryWrapper.java:123)\n\tat<br>&gt; io.apiman.gateway.engine.impl.SecureRegistryWrapper$1.handle(SecureRegistryWrapper.java:112)\n\tat<br>&gt; io.apiman.gateway.engine.es.CachingESRegistry.getApi(CachingESRegistry.java:115)\n\tat<br>&gt; io.apiman.gateway.engine.impl.SecureRegistryWrapper.getApi(SecureRegistryWrapper.java:112)\n\tat<br>&gt; io.apiman.gateway.engine.impl.ApiRequestExecutorImpl.execute(ApiRequestExecutorImpl.java:252)\n\tat<br>&gt; io.apiman.gateway.platforms.servlet.GatewayServlet.doAction(GatewayServlet.java:179)\n\tat<br>&gt; io.apiman.gateway.platforms.servlet.GatewayServlet.service(GatewayServlet.java:79)\n\tat<br>&gt; javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat<br>&gt; io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)\n\tat<br>&gt; io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)\n\tat<br>&gt; io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)\n\tat<br>&gt; org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)\n\tat<br>&gt; io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat<br>&gt; io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)\n\tat<br>&gt; io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)\n\tat<br>&gt; io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat<br>&gt; io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)\n\tat<br>&gt; io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)\n\tat<br>&gt; io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)\n\tat<br>&gt; io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)\n\tat<br>&gt; io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)\n\tat<br>&gt; io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)\n\tat<br>&gt; io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat<br>&gt; org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)\n\tat<br>&gt; io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat<br>&gt; io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat<br>&gt; io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)\n\tat<br>&gt; io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)\n\tat<br>&gt; io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)\n\tat<br>&gt; io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)\n\tat<br>&gt; io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)\n\tat<br>&gt; io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)\n\tat<br>&gt; java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat<br>&gt; java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat<br>&gt; java.lang.Thread.run(Thread.java:745)\nCaused by: java.io.IOException: Not<br>&gt; connected.\n\tat<br>&gt; io.apiman.gateway.platforms.servlet.connectors.HttpApiConnection.write(HttpApiConnection.java:319)\n\t...<br>&gt; 48 more\n&quot;<br>&gt;<br>&gt; }<br>&gt;<br>&gt;  <br>&gt;<br>&gt; Regards,<br>&gt;<br>&gt;  <br>&gt;<br>&gt; Amit Joshi<br>&gt;<br>&gt;  <br>&gt;<br>&gt;  <br>&gt;<br>&gt;<br>&gt; ________________________________<br>&gt;<br>&gt; This e-mail, including accompanying communications and attachments, is<br>&gt; strictly confidential and only for the intended recipient. Any retention,<br>&gt; use or disclosure not expressly authorised by Markit is prohibited. This<br>&gt; email is subject to all waivers and other terms at the following link:<br>&gt; <a href="http://www.markit.com/en/about/legal/email-disclaimer.page">http://www.markit.com/en/about/legal/email-disclaimer.page</a><br>&gt;<br>&gt; Please visit <a href="http://www.markit.com/en/about/contact/contact-us.page">http://www.markit.com/en/about/contact/contact-us.page</a> for<br>&gt; contact information on our offices worldwide.<br>&gt;<br>&gt; _______________________________________________<br>&gt; Apiman-user mailing list<br>&gt; <a href="mailto:Apiman-user@lists.jboss.org">Apiman-user@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/apiman-user">https://lists.jboss.org/mailman/listinfo/apiman-user</a><br>&gt;</div></div>