本文整理汇总了Java中javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory方法的典型用法代码示例。如果您正苦于以下问题:Java HttpsURLConnection.getDefaultSSLSocketFactory方法的具体用法?Java HttpsURLConnection.getDefaultSSLSocketFactory怎么用?Java HttpsURLConnection.getDefaultSSLSocketFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.net.ssl.HttpsURLConnection
的用法示例。
在下文中一共展示了HttpsURLConnection.getDefaultSSLSocketFactory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TestEnvironment
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
public TestEnvironment() {
this.tmpDir = System.getProperty("java.io.tmpdir");
if (tmpDir == null || tmpDir.length() == 0) {
throw new AssertionError("tmpDir is null or empty: " + tmpDir);
}
System.setProperties(null); // Reset.
// From "L" release onwards, calling System.setProperties(null) clears the java.io.tmpdir,
// so we set it again. No-op on earlier releases.
System.setProperty("java.io.tmpdir", tmpDir);
String userHome = System.getProperty("user.home");
String userDir = System.getProperty("user.dir");
if (userHome == null || userDir == null) {
throw new NullPointerException("user.home=" + userHome + ", user.dir=" + userDir);
}
defaultHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
defaultSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
disableSecurity();
}
示例2: register
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
/**
* Easy way of not worrying about stupid SSL validation.
*/
public static void register()
{
if( !(HttpsURLConnection.getDefaultSSLSocketFactory() instanceof BlindSSLSocketFactory) )
{
originalFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
originalHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
LOGGER.info("Registering BlindSSLSocketFactory");
HttpsURLConnection.setDefaultSSLSocketFactory(getDefaultSSL());
// I'm not sure if you need this...
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier()
{
@Override
public boolean verify(String hostname, SSLSession session)
{
return true;
}
});
}
}
示例3: copyWithDefaults
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
/**
* Returns a shallow copy of this OkHttpClient that uses the system-wide default for
* each field that hasn't been explicitly configured.
*/
private OkHttpClient copyWithDefaults() {
OkHttpClient result = new OkHttpClient(this);
result.proxy = proxy;
result.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
result.cookieHandler = cookieHandler != null ? cookieHandler : CookieHandler.getDefault();
result.responseCache = responseCache != null ? responseCache : ResponseCache.getDefault();
result.sslSocketFactory = sslSocketFactory != null
? sslSocketFactory
: HttpsURLConnection.getDefaultSSLSocketFactory();
result.hostnameVerifier = hostnameVerifier != null
? hostnameVerifier
: OkHostnameVerifier.INSTANCE;
result.authenticator = authenticator != null
? authenticator
: HttpAuthenticator.SYSTEM_DEFAULT;
result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault();
result.followProtocolRedirects = followProtocolRedirects;
result.transports = transports != null ? transports : DEFAULT_TRANSPORTS;
result.connectTimeout = connectTimeout;
result.readTimeout = readTimeout;
return result;
}
示例4: initSocketFactoryDefault
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
private static void initSocketFactoryDefault()
{
try
{
socketFactoryDefault = HttpsURLConnection.getDefaultSSLSocketFactory();
javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
javax.net.ssl.TrustManager tm = new TM();
trustAllCerts[0] = tm;
javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
socketFactory = sc.getSocketFactory();
}
catch(Exception e)
{
e.printStackTrace();
}
}
示例5: NoSSLv3SocketFactory
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
public NoSSLv3SocketFactory() {
this.delegate = HttpsURLConnection.getDefaultSSLSocketFactory();
}
示例6: testHTTPS
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
@Test
public void testHTTPS() throws Exception {
Config config = buildHTTPSConfig();
startServer(config);
// Turn off actual checking of the dummy SSL cert
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new TrustManager[] { ACCEPT_ALL_TM }, null);
SSLSocketFactory originalFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
try {
String response = Resources.toString(
new URL("https://localhost:" + getHTTPSPort() + "/helloWorld"),
StandardCharsets.UTF_8);
assertEquals("Hello, World", response);
} finally {
// Restore original SSL factory
HttpsURLConnection.setDefaultSSLSocketFactory(originalFactory);
Files.delete(Paths.get(config.getString("oryx.serving.api.keystore-file")));
}
}
示例7: getDefaultSSLSocketFactory
import javax.net.ssl.HttpsURLConnection; //导入方法依赖的package包/类
public static SSLSocketFactory getDefaultSSLSocketFactory() {
return HttpsURLConnection.getDefaultSSLSocketFactory();
}