<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
JNDI over SSL Naming problem
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/pfennig">Elad o</a> in <i>JNDI and Naming</i> - <a href="https://community.jboss.org/message/788699#788699">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi everyone and thanks to anyone reading this post.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I've been struggling a few days, trying to change the communication of my client-server JNDI lookup from http to https.</p><p>I'm using JBoss 4.2.0 and upgrading it is currently not an option.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>What I did in the client is to change the url as advised in the jboss manual. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><table><tbody><tr><td style=";"></td><td style=";"></td><td style=";"><br/></td></tr><tr><td style=";"></td><td style=";"></td><td style=";">System.setProperty("javax.net.ssl.trustStore", "C:/Program Files (x86)/localhost.truststore");</td></tr><tr><td style=";"></td><td style=";"></td><td style=";">System.setProperty("javax.net.ssl.trustStoreType", "JKS");</td></tr><tr><td style=";"></td><td style=";"></td><td style=";">System.setProperty("javax.net.ssl.trustStorePassword", "opensource");</td><td style=";"></td><td style=";"></td></tr><tr><td style=";"></td><td style=";"></td><td style=";">System.setProperty(HTTPSClientInvoker.IGNORE_HTTPS_HOST,"true");</td></tr><tr><td style=";"></td><td style=";"></td><td style=";"></td></tr><tr><td style=";"></td><td style=";"></td><td style=";">jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");</td></tr><tr><td style=";"></td><td style=";"></td><td style=";"><br/></td></tr><tr><td style=";"></td><td style=";"></td><td style=";"><p><span>jndiProperties.put(Context.PROVIDER_URL, "</span><a class="jive-link-external-small" href="https://" target="_blank">https://</a><span>"+serverIp+":8443/invoker/JNDIFactory"</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><table><tbody><tr><td style=";"></td><td style=";"></td><td style=";">final Context context = new InitialContext(jndiProperties);</td></tr><tr><td style=";"></td><td style=";"></td><td style=";"></td></tr><tr><td style=";"></td><td style=";"></td><td style=";">T facade = (T) context.lookup(facadeName);</td></tr><tr><td style=";"></td><td style=";"></td><td style=";">return facade;</td></tr></tbody></table></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>previously the url was: </p><p>jndiProperties.put(Context.PROVIDER_URL, "jnp://"+serverIp+":1099");</p><p>and the contextfactory was</p><p>jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>the serverIp is the real server the user enters. I don't want to use a network host name since I don't have a dns server in my server.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I didn't have any problem with the jnp url and the jnp naming factory, but when I try the access over SSL, the Jboss code in </p><p>HTTPNamingContextFactory.getNamingServer(URL providerURL) overrides my ip with a host name the client doesn't recognize.</p><p>It does some marshalling from the server and takes the first host entry which is defined in my linux server hosts file.</p><p>The HttpInvokerProxy does that eventually by writing the externalURLValue from the server, which is:</p><p><a class="jive-link-external-small" href="https://myhost:8443/invoker/JMXInvokerServlet" target="_blank">https://myhost:8443/invoker/JMXInvokerServlet</a><span>. </span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>My client doesn't know what to do with this "myhost", it needs the real ip of the server, which I initially provide in the JNDI properties in the client.</p><p>The only thing I was able to do is edit the hosts file in the client windows system hosts file, and add an entry myhosts with the real ip, but this is of course </p><p>not a solution for a production environment, since I can't ask my user to make such modifications. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>So I get this exception in the client:</p><p>javax.naming.CommunicationException: Operation failed [Root exception is java.rmi.ServerException: IOE; nested exception is: </p><p>    java.net.UnknownHostException: myhost</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>My server's deploy/http-invoker.sar/META-INF/jboss-service.xml is below, if I try to set useHostName to false, then the localhost ip would be used</p><p>127.0.0.1 instead of myhost, which isn't any helpful, since I just need to keep my initially provided ip.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'm a newbee to JBoss so I will appreciate any answer as to what am I doing wrong, and how can I resolve this without upgrade of JBOSS.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thank You</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><?xml version="1.0" encoding="UTF-8"?></p><p><!DOCTYPE server></p><p><!-- $Id: jboss-service.xml 26202 2004-11-29 16:54:36Z starksm $ --></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><server></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <!-- The HTTP invoker service configration</p><p>  --></p><p>  <mbean code="org.jboss.invocation.http.server.HttpInvoker"</p><p>    name="jboss:service=invoker,type=https"></p><p><span>     <!-- Use a URL of the form </span><a class="jive-link-external-small" href="http://" target="_blank">http://</a><span><hostname>:8080/invoker/EJBInvokerServlet</span></p><p>      where <hostname> is InetAddress.getHostname value on which the server</p><p>      is running.</p><p>      --></p><p><span>     <attribute name="InvokerURLPrefix"></span><a class="jive-link-external-small" href="https://" target="_blank">https://</a><span></attribute></span></p><p>     <attribute name="InvokerURLSuffix">:${https.port}/invoker/EJBInvokerServlet</attribute></p><p>     <attribute name="UseHostName">true</attribute></p><p>  </mbean></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   <!-- Expose the Naming service interface via HTTP --></p><p>   <mbean code="org.jboss.invocation.http.server.HttpProxyFactory"</p><p>      name="jboss:service=invoker,type=http,target=Naming"></p><p>      <!-- The Naming service we are proxying --></p><p>      <attribute name="InvokerName">jboss:service=Naming</attribute></p><p>      <!-- Compose the invoker URL from the cluster node address --></p><p><span>      <attribute name="InvokerURLPrefix"></span><a class="jive-link-external-small" href="https://" target="_blank">https://</a><span></attribute></span></p><p>      <attribute name="InvokerURLSuffix">:${https.port}/invoker/JMXInvokerServlet</attribute></p><p>      <attribute name="UseHostName">true</attribute></p><p>      <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute></p><p>      <attribute name="JndiName"></attribute></p><p>      <attribute name="ClientInterceptors"></p><p>          <interceptors></p><p>             <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor></p><p>             <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor></p><p>             <interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor></p><p>             <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor></p><p>          </interceptors></p><p>      </attribute></p><p>   </mbean></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>   <!-- Expose the Naming service interface via clustered HTTP. This maps</p><p>   to the ReadOnlyJNDIFactory servlet URL</p><p>   --></p><p>   <mbean code="org.jboss.invocation.http.server.HttpProxyFactory"</p><p>      name="jboss:service=invoker,type=http,target=Naming,readonly=true"></p><p>      <attribute name="InvokerName">jboss:service=Naming</attribute></p><p><span>      <attribute name="InvokerURLPrefix"></span><a class="jive-link-external-small" href="http://" target="_blank">http://</a><span></attribute></span></p><p>      <attribute name="InvokerURLSuffix">:8080/invoker/readonly/JMXInvokerServlet</attribute></p><p>      <attribute name="UseHostName">true</attribute></p><p>      <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute></p><p>      <attribute name="JndiName"></attribute></p><p>      <attribute name="ClientInterceptors"></p><p>          <interceptors></p><p>             <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor></p><p>             <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor></p><p>             <interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor></p><p>             <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor></p><p>          </interceptors></p><p>      </attribute></p><p>   </mbean></p><p></server></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/788699#788699">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JNDI and Naming at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>