Https SSL上的JNDI UnknownHostException
大家好,感谢所有阅读本文的人 我已经挣扎了几天,试图将客户端服务器JNDI查找的通信从http更改为https 我正在使用JBoss4.2.0,升级它目前不是一个选项 我在客户端所做的是按照jboss手册中的建议更改urlHttps SSL上的JNDI UnknownHostException,https,jboss,jndi,naming,Https,Jboss,Jndi,Naming,大家好,感谢所有阅读本文的人 我已经挣扎了几天,试图将客户端服务器JNDI查找的通信从http更改为https 我正在使用JBoss4.2.0,升级它目前不是一个选项 我在客户端所做的是按照jboss手册中的建议更改url System.setProperty("javax.net.ssl.trustStore", "C:/Program Files (x86)/localhost.truststore"); System.setProperty("javax.net.ssl.t
System.setProperty("javax.net.ssl.trustStore", "C:/Program Files (x86)/localhost.truststore");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStorePassword", "opensource");
System.setProperty(HTTPSClientInvoker.IGNORE_HTTPS_HOST,"true");
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.HttpNamingContextFactory");
jndiProperties.put(Context.PROVIDER_URL, "https://"+serverIp+":8443/invoker/JNDIFactory"
final Context context = new InitialContext(jndiProperties);
T facade = (T) context.lookup(facadeName);
return facade;
以前的url是:
jndiProperties.put(Context.PROVIDER_URL, "jnp://"+serverIp+":1099");
而contextfactory是
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
serverIp是用户进入的真正服务器。我不想使用网络主机名,因为我的服务器中没有dns服务器
我对jnp url和jnp命名工厂没有任何问题,但是当我尝试通过SSL访问时,HTTPNamingContextFactory.getNamingServer(url providerURL)
中的Jboss代码用客户端无法识别的主机名覆盖我的ip
它从服务器进行一些编组,并获取在我的linux服务器主机文件中定义的第一个主机条目
HttpInvokerProxy最终通过从服务器写入externalURLValue来实现这一点,即:
"https://myhost:8443/invoker/JMXInvokerServlet".
我的客户机不知道如何处理这个“myhost”,它需要服务器的真实ip,这是我最初在客户机的JNDI属性中提供的
我唯一能做的就是在客户端windows系统主机文件中编辑主机文件,并添加一个具有真实ip的条目myhosts,但这当然是正确的
这不是生产环境的解决方案,因为我无法要求用户进行此类修改
所以我在客户机中得到了这个异常:
javax.naming.CommunicationException:操作失败[根异常为java.rmi.ServerException:IOE;嵌套异常为:
java.net.UnknownHostException: myhost
我的服务器的deploy/http-invoker.sar/META-INF/jboss-service.xml如下所示,如果我尝试将useHostName设置为false,则将使用本地主机ip
127.0.0.1而不是myhost,这没有任何帮助,因为我只需要保留最初提供的ip
我是JBoss的新手,所以我很感激任何关于我做错了什么的答案,以及在不升级JBoss的情况下如何解决这个问题
多谢各位
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<!-- $Id: jboss-service.xml 26202 2004-11-29 16:54:36Z starksm $ -->
<server>
<!-- The HTTP invoker service configration
-->
<mbean code="org.jboss.invocation.http.server.HttpInvoker"
name="jboss:service=invoker,type=https">
<!-- Use a URL of the form http://<hostname>:8080/invoker/EJBInvokerServlet
where <hostname> is InetAddress.getHostname value on which the server
is running.
-->
<attribute name="InvokerURLPrefix">https://</attribute>
<attribute name="InvokerURLSuffix">:${https.port}/invoker/EJBInvokerServlet</attribute>
<attribute name="UseHostName">true</attribute>
</mbean>
<!-- Expose the Naming service interface via HTTP -->
<mbean code="org.jboss.invocation.http.server.HttpProxyFactory"
name="jboss:service=invoker,type=http,target=Naming">
<!-- The Naming service we are proxying -->
<attribute name="InvokerName">jboss:service=Naming</attribute>
<!-- Compose the invoker URL from the cluster node address -->
<attribute name="InvokerURLPrefix">https://</attribute>
<attribute name="InvokerURLSuffix">:${https.port}/invoker/JMXInvokerServlet</attribute>
<attribute name="UseHostName">true</attribute>
<attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
<attribute name="JndiName"></attribute>
<attribute name="ClientInterceptors">
<interceptors>
<interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
<interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
<interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor>
<interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
</interceptors>
</attribute>
</mbean>
<!-- Expose the Naming service interface via clustered HTTP. This maps
to the ReadOnlyJNDIFactory servlet URL
-->
<mbean code="org.jboss.invocation.http.server.HttpProxyFactory"
name="jboss:service=invoker,type=http,target=Naming,readonly=true">
<attribute name="InvokerName">jboss:service=Naming</attribute>
<attribute name="InvokerURLPrefix">http://</attribute>
<attribute name="InvokerURLSuffix">:8080/invoker/readonly/JMXInvokerServlet</attribute>
<attribute name="UseHostName">true</attribute>
<attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
<attribute name="JndiName"></attribute>
<attribute name="ClientInterceptors">
<interceptors>
<interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
<interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
<interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor>
<interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
</interceptors>
</attribute>
</mbean>
</server>
https://
:${https.port}/invoker/EJBInvokerServlet
真的
jboss:service=Naming
https://
:${https.port}/invoker/JMXInvokerServlet
真的
org.jnp.interfaces.Naming
org.jboss.proxy.ClientMethodInterceptor
org.jboss.proxy.SecurityInterceptor
org.jboss.naming.interceptors.ExceptionInterceptor
org.jboss.invocation.InvokerInterceptor
jboss:service=Naming
http://
:8080/invoker/readonly/JMXInvokerServlet
真的
org.jnp.interfaces.Naming
org.jboss.proxy.ClientMethodInterceptor
org.jboss.proxy.SecurityInterceptor
org.jboss.naming.interceptors.ExceptionInterceptor
org.jboss.invocation.InvokerInterceptor
是否检查了java.rmi.server.hostname、tomcat.proxyName和tomcat.sslProxyName属性的值?(可以使用JMXConsole中的SystemProperties MBean检查它们的值)
我不知道HTTP Inovker Servlet从何处获取服务器名称,但它可能会使用这些属性之一。请尝试将它们定义为您希望它使用的ip,但请小心,因为这可能会改变其他服务/应用程序的行为