我已经编写了一个带注释的示例客户端端点,如下所示,
public WebsocketSSLClientEndpoint(URI endpointURI) throws URISyntaxException {
final ClientManager client = ClientManager.createClient();
try {
System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, "/tmp/ServerId.jks");
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, "/tmp/ServerTrust.jks");
System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "ServerKeyStorePassPhrase");
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "ServerTrustStorePassPhrase");
System.getProperties().put("javax.net.debug", "all");
SslEngineConfigurator sslEngineConfigurator = new SslEngineConfigurator(new SslContextConfigurator());
sslEngineConfigurator.setHostVerificationEnabled(false); //skip host verification
client.getProperties().put(ClientProperties.SSL_ENGINE_CONFIGURATOR, sslEngineConfigurator);
System.out.println("before connect");
client.connectToServer(this, endpointURI);
System.out.println("after connect");
然而,当我尝试连接时,
uri = new URI ("wss://foo.bar.com:8002/ws/echo");
System.out.println("WebSocket Address used is : "+uri.toString());
// open websocket
final WebsocketSSLClientEndpoint clientEndPoint = new WebsocketSSLClientEndpoint(uri);
我得到以下异常,
javax.websocket.DeploymentException: KeyManagerFactoryImpl is not initialized
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket.connect(GrizzlyClientSocket.java:255)
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientContainer.openClientSocket(GrizzlyClientContainer.java:95)
at org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:663)
at org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:712)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Caused by: java.lang.IllegalStateException: KeyManagerFactoryImpl is not initialized
at sun.security.ssl.KeyManagerFactoryImpl.engineGetKeyManagers(KeyManagerFactoryImpl.java:51)
at javax.net.ssl.KeyManagerFactory.getKeyManagers(KeyManagerFactory.java:289)
at org.glassfish.tyrus.client.SslContextConfigurator.createSSLContext(SslContextConfigurator.java:734)
at org.glassfish.tyrus.client.SslEngineConfigurator.getSslContext(SslEngineConfigurator.java:441)
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket$ExtendedSSLEngineConfigurator.<init>(GrizzlyClientSocket.java:892)
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket.getSSLEngineConfigurator(GrizzlyClientSocket.java:771)
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket._connect(GrizzlyClientSocket.java:374)
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket.access$000(GrizzlyClientSocket.java:103)
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket$1.call(GrizzlyClientSocket.java:235)
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket$1.call(GrizzlyClientSocket.java:231)
at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientSocket.connect(GrizzlyClientSocket.java:249)
... 11 more
我错过了什么吗?请问您能否共享可用的基于java的ssl客户端Web套接字端点
由于