本文整理汇总了Java中sun.security.ssl.SSLSocketImpl类的典型用法代码示例。如果您正苦于以下问题:Java SSLSocketImpl类的具体用法?Java SSLSocketImpl怎么用?Java SSLSocketImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SSLSocketImpl类属于sun.security.ssl包,在下文中一共展示了SSLSocketImpl类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFreshSocket
import sun.security.ssl.SSLSocketImpl; //导入依赖的package包/类
private SSLSocketImpl getFreshSocket(ProtocolVersion version) throws IOException, Exception {
SSLContext allowAllContext = getAllowAllContext();
SSLSocketFactory sslFact = allowAllContext.getSocketFactory();
SSLSocketImpl socket = (SSLSocketImpl) sslFact.createSocket(serverHost, serverPort);
socket.setEnabledCipherSuites(new String[] { cipherSuite.name() });
String versions[] = new String[1];
switch (version) {
case SSL3:
versions[0] = "SSLv3";
break;
case TLS10:
versions[0] = "TLSv1";
break;
case TLS11:
versions[0] = "TLSv1.1";
break;
case TLS12:
versions[0] = "TLSv1.2";
break;
default:
throw new UnsupportedOperationException("This version is not supported");
}
socket.setEnabledProtocols(versions);
return socket;
}