在HTTPS中使用javax.xml.ws.Endpoint

在HTTPS中使用javax.xml.ws.Endpoint,第1张

在HTTPS中使用javax.xml.ws.Endpoint

对于服务器:

SSLContext ssl = SSLContext.getInstance("TLS");KeyManagerFactory keyFactory = KeyManagerFactory         .getInstance(KeyManagerFactory.getDefaultAlgorithm());KeyStore store = KeyStore.getInstance("JKS");store.load(new FileInputStream(keystoreFile),keyPass.toCharArray());keyFactory.init(store, keyPass.toCharArray());TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());trustFactory.init(store);ssl.init(keyFactory.getKeyManagers(),trustFactory.getTrustManagers(), new SecureRandom());HttpsConfigurator configurator = new HttpsConfigurator(ssl);HttpsServer httpsServer = HttpsServer.create(new InetSocketAddress(hostname, port), port);httpsServer.setHttpsConfigurator(configurator);HttpContext httpContext = httpsServer.createContext(uri);httpsServer.start();endpoint.publish(httpContext);

对于客户,请确保您执行以下 *** 作

System.setProperty("javax.net.ssl.trustStore", "path");System.setProperty("javax.net.ssl.keyStore", "password");System.setProperty("javax.net.ssl.keyStorePassword", "password");System.setProperty("javax.net.ssl.keyStoreType", "JKS");//done to prevent CN verification in client keystoreHttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {   @Override   public boolean verify(String hostname, SSLSession session) {     return true;   }});


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5093091.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存