SSL java.security.NoSuchAlgorithmException

时间:2017-04-13 08:54:57

标签: java sockets ssl

Java说在这一行中找不到文件ssc.store:

server = ((SSLServerSocketFactory) SSLServerSocketFactory.getDefault()).createServerSocket(port);

(服务器是ServerSocket)

我尝试使用包含此代码的库,但我无法打开此ServerSocket。

完全错误

Error opening ServerSocket
java.net.SocketException: java.security.NoSuchAlgorithmException: Error 
constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at javax.net.ssl.DefaultSSLServerSocketFactory.throwException(Unknown Source)
at javax.net.ssl.DefaultSSLServerSocketFactory.createServerSocket(Unknown Source)
at com.blogspot.debukkitsblog.Net.Server.start(Server.java:327)
at com.blogspot.debukkitsblog.Net.Server.<init>(Server.java:86)
at com.blogspot.debukkitsblog.Net.Server.<init>(Server.java:51)
at de.yee.GameServer.<init>(GameServer.java:16)
at de.yee.Main.main(Main.java:9)
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at java.security.Provider$Service.newInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at javax.net.ssl.SSLContext.getInstance(Unknown Source)
at javax.net.ssl.SSLContext.getDefault(Unknown Source)
at javax.net.ssl.SSLServerSocketFactory.getDefault(Unknown Source)
... 5 more
Caused by: java.security.PrivilegedActionException: java.io.FileNotFoundException: ssc.store (Das System kann die angegebene Datei nicht finden)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.ssl.SSLContextImpl$DefaultManagersHolder.getKeyManagers(Unknown Source)
at sun.security.ssl.SSLContextImpl$DefaultManagersHolder.<clinit>(Unknown Source)
at sun.security.ssl.SSLContextImpl$DefaultSSLContext.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
... 11 more
Caused by: java.io.FileNotFoundException: ssc.store (Das System kann die angegebene Datei nicht finden)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.security.ssl.SSLContextImpl$DefaultManagersHolder$2.run(Unknown Source)
at sun.security.ssl.SSLContextImpl$DefaultManagersHolder$2.run(Unknown Source)
... 19 more

有什么问题?

1 个答案:

答案 0 :(得分:2)

您需要在运行代码的工作目录中使用ssc.store文件。商店位于:https://github.com/DeBukkIt/SimpleServerClient/blob/master/ssc.store(或您签出的特定分支或标签)。

例如,如果您在IntelliJ中运行main方法,则存储文件应位于项目根目录中。或者,如果将应用程序打包到jar并运行java -jar yourapp.jar,则ssc.store应与jar文件位于同一目录中。