栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在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;   }});


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/428379.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号