Java 玻璃鱼4号&x2B;SSL client=连接失败:socketType:SSL;主机名:127.0.0.1

Java 玻璃鱼4号&x2B;SSL client=连接失败:socketType:SSL;主机名:127.0.0.1,java,jakarta-ee,ssl,glassfish,Java,Jakarta Ee,Ssl,Glassfish,我有一个glassfish服务器,我想通过SSL从独立的swing客户端连接到EJB。没有SSL,一切正常 当我尝试使用此环境在客户端中创建InitialContext时: hashtable.put("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory"); hashtable.put("java.naming.factory.url.pkgs", "com.sun.ent

我有一个glassfish服务器,我想通过SSL从独立的swing客户端连接到EJB。没有SSL,一切正常

当我尝试使用此环境在客户端中创建InitialContext时:

hashtable.put("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
hashtable.put("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
hashtable.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
hashtable.put("org.omg.CORBA.ORBInitialHost", serverIp);
hashtable.put("org.omg.CORBA.ORBInitialPort", 3820);
此外,我使用以下JVM参数:

-Djavax.net.ssl.trustStorePassword=changeit \
-Djavax.net.ssl.trustStore=./myTrustStore\
-Dcom.sun.CSIV2.ssl.standalone.client.required=true\
-Dorg.omg.CORBA.ORBInitialPort=3820 \
我得到了以下方面的信息:

javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, org.omg.CORBA.ORBInitialHost=10.0.17.2, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is java.rmi.MarshalException: CORBA COMM_FAILURE 1330446337 No; nested exception is: 
    org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: SSL; hostname: 127.0.0.1; port: 3820  vmcid: OMG  minor code: 1  completed: No]
....
Caused by: java.rmi.MarshalException: CORBA COMM_FAILURE 1330446337 No; nested exception is: 
    org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: SSL; hostname: 127.0.0.1; port: 3820  vmcid: OMG  minor code: 1  completed: No
...
Caused by: org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: SSL; hostname: 127.0.0.1; port: 3820  vmcid: OMG  minor code: 1  completed: No
    at com.sun.proxy.$Proxy17.connectFailure(Unknown Source)
...
Caused by: java.lang.RuntimeException: java.io.IOException: Error opening SSL socket to host=home.home port=3820
...
Caused by: java.io.IOException: Error opening SSL socket to host=home.home port=3820
...
Caused by: java.net.ConnectException: Connection refused
家是我的工作站。完整日志为

请解释为什么它试图打开到localhost而不是serverIp的连接

编辑:这是我的sun-ejb-jar.xml(服务器端)

编辑3
我已经从自己的来源建造了玻璃鱼(GF 4.0.1)。我现在拥有的。当客户机和服务器在同一台主机上时,一切似乎都正常工作。客户端获取EJB,EJB将信息写入日志。对我又查了一遍。所有数据包都通过接口lo。在服务器端端口3820上。一切都好

但当他们在不同的主机上时,我也不例外。Tcpdump让我们感激地看到,我们每一分钟都在关注,而且这一点一直在持续(我还是在晚上离开):

其中10.0.17.2我的GF服务器。这是服务器日志的结尾:

[2014-06-04T09:17:18.369+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=143 _ThreadName=Thread-8] [timeMillis: 1401859038369] [levelValue: 800] [[
  p: thread-pool-1; w: 2, WRITE: TLSv1 Application Data, length = 32]]
[2014-06-04T09:17:18.369+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=143 _ThreadName=Thread-8] [timeMillis: 1401859038369] [levelValue: 800] [[
  p: thread-pool-1; w: 2, WRITE: TLSv1 Application Data, length = 288]]
[2014-06-04T09:18:21.220+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=142 _ThreadName=Thread-8] [timeMillis: 1401859101220] [levelValue: 800] [[
  p: thread-pool-1; w: 1, READ: TLSv1 Application Data, length = 32]]
[2014-06-04T09:18:21.220+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=142 _ThreadName=Thread-8] [timeMillis: 1401859101220] [levelValue: 800] [[
  p: thread-pool-1; w: 1, READ: TLSv1 Application Data, length = 144]]
[2014-06-04T09:18:21.222+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=142 _ThreadName=Thread-8] [timeMillis: 1401859101222] [levelValue: 800] [[
  p: thread-pool-1; w: 1, WRITE: TLSv1 Application Data, length = 32]]
[2014-06-04T09:18:21.222+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=142 _ThreadName=Thread-8] [timeMillis: 1401859101222] [levelValue: 800] [[
  p: thread-pool-1; w: 1, WRITE: TLSv1 Application Data, length = 288]]
我是说写,读,写,读等等。
据我所知,如果它在同一台主机上工作,则意味着客户端在某个点连接到127.0.0.1 3820。因此,在设置中有必要将其更改为真正的服务器ip。

我自己解决了这个问题。在linux机器上,有必要在/etc/hosts文件中设置服务器IP。因为glassfish使用函数

InetAddress.getLocalHost()

获取服务器IP。我没有在此文件中设置服务器IP。这就是为什么在ssl协商期间,当建立新连接时,glassfish试图打开127.0.0.1的连接,而不是真正的服务器IP。

请参见@Niemand,我已经阅读了这个问题。但它试图连接到正确的IP。在这里,我不知道为什么客户端试图连接到它的本地主机而不是服务器。serverIp变量中有什么?为什么是hashtable而不仅仅是Properties类?正如我很久以前测试的那样,我将
ORBInitialPort
设置为默认的IIOP端口,例如
3700
,在调用EJB时,它将重定向到SSL端口。@Charlee Chitsuk我指的是客户端javax.net.SSL.SSLException:无法识别的SSL消息,纯文本连接。为什么GF不把它重定向到3820?
    10.0.18.5.55618 > 10.0.17.2.3820: Flags [.], cksum 0xa8e4 (correct), seq 76855, ack 136375, win 499, options [nop,nop,TS val 669632607 ecr 224087792], length 0
08:44:46.148416 IP (tos 0x0, ttl 64, id 38301, offset 0, flags [DF], proto TCP (6), length 52)
    10.0.18.5.55618 > 10.0.17.2.3820: Flags [.], cksum 0xa7c1 (correct), seq 76855, ack 136668, win 497, options [nop,nop,TS val 669632607 ecr 224087792], length 0
08:45:48.965565 IP (tos 0x0, ttl 64, id 38302, offset 0, flags [DF], proto TCP (6), length 238)
    10.0.18.5.55618 > 10.0.17.2.3820: Flags [P.], cksum 0xdf9c (correct), seq 76855:77041, ack 136668, win 499, options [nop,nop,TS val 669695423 ecr 224087792], length 186
08:45:48.966448 IP (tos 0x0, ttl 64, id 3268, offset 0, flags [DF], proto TCP (6), length 89)
    10.0.17.2.3820 > 10.0.18.5.55618: Flags [P.], cksum 0x3752 (incorrect -> 0xe28f), seq 136668:136705, ack 77041, win 501, options [nop,nop,TS val 224150610 ecr 669695423], length 37
08:45:48.966520 IP (tos 0x0, ttl 64, id 3269, offset 0, flags [DF], proto TCP (6), length 345)
    10.0.17.2.3820 > 10.0.18.5.55618: Flags [P.], cksum 0x3852 (incorrect -> 0xbd0f), seq 136705:136998, ack 77041, win 501, options [nop,nop,TS val 224150610 ecr 669695423], length 293
08:45:48.966702 IP (tos 0x0, ttl 64, id 38303, offset 0, flags [DF], proto TCP (6), length 52)
    10.0.18.5.55618 > 10.0.17.2.3820: Flags [.], cksum 0xbc1b (correct), seq 77041, ack 136705, win 499, options [nop,nop,TS val 669695424 ecr 224150610], length 0
08:45:48.966962 IP (tos 0x0, ttl 64, id 38304, offset 0, flags [DF], proto TCP (6), length 52)
    10.0.18.5.55618 > 10.0.17.2.3820: Flags [.], cksum 0xbaf8 (correct), seq 77041, ack 136998, win 497, options [nop,nop,TS val 669695424 ecr 224150610], length 0
[2014-06-04T09:17:18.369+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=143 _ThreadName=Thread-8] [timeMillis: 1401859038369] [levelValue: 800] [[
  p: thread-pool-1; w: 2, WRITE: TLSv1 Application Data, length = 32]]
[2014-06-04T09:17:18.369+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=143 _ThreadName=Thread-8] [timeMillis: 1401859038369] [levelValue: 800] [[
  p: thread-pool-1; w: 2, WRITE: TLSv1 Application Data, length = 288]]
[2014-06-04T09:18:21.220+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=142 _ThreadName=Thread-8] [timeMillis: 1401859101220] [levelValue: 800] [[
  p: thread-pool-1; w: 1, READ: TLSv1 Application Data, length = 32]]
[2014-06-04T09:18:21.220+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=142 _ThreadName=Thread-8] [timeMillis: 1401859101220] [levelValue: 800] [[
  p: thread-pool-1; w: 1, READ: TLSv1 Application Data, length = 144]]
[2014-06-04T09:18:21.222+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=142 _ThreadName=Thread-8] [timeMillis: 1401859101222] [levelValue: 800] [[
  p: thread-pool-1; w: 1, WRITE: TLSv1 Application Data, length = 32]]
[2014-06-04T09:18:21.222+0400] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=142 _ThreadName=Thread-8] [timeMillis: 1401859101222] [levelValue: 800] [[
  p: thread-pool-1; w: 1, WRITE: TLSv1 Application Data, length = 288]]
InetAddress.getLocalHost()