简体   繁体   English

使用Java SSLSocket时,Windows和Linux / OS X有什么区别?

[英]What's the difference between Windows and Linux/OS X when using the Java SSLSocket?

I wrote a multi-server chat system based on Java under Windows. 我在Windows下编写了一个基于Java的多服务器聊天系统。 At the security part, I created one keystore to create the SSLSocket. 在安全性部分,我创建了一个密钥库来创建SSLSocket。 When I launch 3 servers, it works on Windows(Win10 14393.321) but fails on OS X(Version 10.12 (16A323)) and Linux(Ubuntu 14.04.4 LTS). 当我启动3台服务器时,它可以在Windows(Win10 14393.321)上运行,但在OS X(版本10.12(16A323))和Linux(Ubuntu 14.04.4 LTS)上无法运行。 It really confused me. 这真的让我感到困惑。 Here is the keystore part: 这是密钥库部分:

System.setProperty("javax.net.ssl.keyStore",keyFilepath);
System.setProperty("javax.net.ssl.trustStore",keyFilepath);
System.setProperty("javax.net.ssl.keyStorePassword","password");
System.setProperty("javax.net.ssl.trustStorePassword", "password");

And when I run the third server on OS X or Linux, it shows: 当我在OS X或Linux上运行第三台服务器时,它显示:

java.net.ConnectException: Connection refused java.net.ConnectException:连接被拒绝

at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668) at sun.security.ssl.SSLSocketImpl.(SSLSocketImpl.java:427) at sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88) at server.AuthorizeServer.MessageReceive(AuthorizeServer.java:99) at server.AuthorizeServer.main(AuthorizeServer.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method. 在java.net.PlainSocketImpl.socketConnect(本地方法)在java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)在java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)在java.net.AbstractPlainSocketImpl.connect (java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)的java.net.Socket.connect(Socket.java:589)的sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl。)(AbstractPlainSocketImpl.java:188) java:668)在sun.security.ssl.SSLSocketImpl。(SSLSocketImpl.java:427)在sun.security.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:88)在server.AuthorizeServer.MessageReceive(AuthorizeServer.java:99)在server.AuthorizeServer.main(AuthorizeServer.java:64)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor .java:43),请访问java.lang.reflect.Method。 invoke(Method.java:497) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) 在org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)处调用(Method.java:497)

This is my first time asking on StackOverflow and I really looking forward to your kind help. 这是我第一次询问StackOverflow,非常期待您的帮助。 Thanks! 谢谢!

java.net.ConnectException: Connection refused java.net.ConnectException:连接被拒绝

Connection refused is an error message from the TCP stack and means that it could not connect with TCP to the other side. 连接被拒绝是来自TCP堆栈的错误消息,表示它无法与TCP连接到另一端。 Since SSL/TLS is a layer on top of TCP and is only started once the TCP connect succeeded it means that the problem is not caused by different behavior at the SSL/TLS layer. 由于SSL / TLS是TCP之上的一层,并且仅在TCP连接成功后才启动,因此这意味着问题不是由SSL / TLS层上的不同行为引起的。

That this is not cause by the SSL layer but the TCP layer can also be seen by the stacktrace: Connection refused at java.net. 这不是由SSL层引起的,而TCP层也可以由stacktrace看到: java.net上的连接被拒绝。 PlainSocket Impl.socketConnect PlainSocket Impl.socketConnect

More likely is that there is something blocking the TCP connection (firewall) or that you've tried to listen/connect to the wrong IP address (eg trying to reach a server listening on 127.0.0.1 on Windows from the Linux system). 更有可能的是,有某些东西阻止了TCP连接(防火墙),或者您试图侦听/连接到错误的IP地址(例如,尝试从Linux系统访问Windows 127.0.0.1上的服务器)。 But is impossible to say from the currently provided information what exactly is the case. 但是从当前提供的信息中无法确切地说出情况是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM