Java Code Examples for javax.net.ssl.HttpsURLConnection#getDefaultSSLSocketFactory()
The following examples show how to use
javax.net.ssl.HttpsURLConnection#getDefaultSSLSocketFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OkHttpClient.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 6 votes |
/** * 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(); result.proxy = proxy; result.failedRoutes = failedRoutes; 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 : HttpsURLConnection.getDefaultHostnameVerifier(); result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault(); result.followProtocolRedirects = followProtocolRedirects; return result; }
Example 2
Source File: OkHttpClient.java From CordovaYoutubeVideoPlayer with MIT License | 6 votes |
/** * 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; }
Example 3
Source File: OkHttpClient.java From L.TileLayer.Cordova with MIT License | 6 votes |
/** * 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; }
Example 4
Source File: SecureAPIConfigIT.java From oryx with Apache License 2.0 | 6 votes |
@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"))); } }
Example 5
Source File: OkHttpClient.java From cordova-android-chromeview with Apache License 2.0 | 6 votes |
/** * 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(); result.proxy = proxy; result.failedRoutes = failedRoutes; 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 : HttpsURLConnection.getDefaultHostnameVerifier(); result.connectionPool = connectionPool != null ? connectionPool : ConnectionPool.getDefault(); result.followProtocolRedirects = followProtocolRedirects; return result; }
Example 6
Source File: OkHttpClient.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
/** * 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; }
Example 7
Source File: SslConnectionIntegrationTest.java From cruise-control with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testSslConnection() throws Exception { assertEquals(HTTPS, new URL(_app.serverUrl()).getProtocol()); SSLSocketFactory defaultSslSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, _trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpURLConnection connection = (HttpURLConnection) new URI(_app.serverUrl()) .resolve(CRUISE_CONTROL_STATE_ENDPOINT).toURL().openConnection(); assertEquals(HttpServletResponse.SC_OK, connection.getResponseCode()); } finally { HttpsURLConnection.setDefaultSSLSocketFactory(defaultSslSocketFactory); } }
Example 8
Source File: OkHttpClient.java From reader with MIT License | 6 votes |
/** * 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; }
Example 9
Source File: OkHttpClient.java From android-discourse with Apache License 2.0 | 6 votes |
/** * 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; }
Example 10
Source File: Https.java From PacketProxy with Apache License 2.0 | 5 votes |
public static String getCommonName(InetSocketAddress addr) throws Exception { SSLSocketFactory ssf = HttpsURLConnection.getDefaultSSLSocketFactory(); SSLSocket socket = (SSLSocket) ssf.createSocket(addr.getAddress(), addr.getPort()); socket.startHandshake(); SSLSession session = socket.getSession(); X509Certificate[] servercerts = (X509Certificate[]) session.getPeerCertificates(); Pattern pattern = Pattern.compile("CN=([^,]+)", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(servercerts[0].getSubjectDN().getName()); if (matcher.find()) { return matcher.group(1); } return ""; }
Example 11
Source File: SessionTest.java From openerp-java-api with Apache License 2.0 | 5 votes |
@BeforeClass public static void startProxy() throws Exception { if (isUsingMockServer()) { previousFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); HttpsURLConnection.setDefaultSSLSocketFactory(SSLFactory.getInstance().sslContext().getSocketFactory()); proxy = ClientAndProxy.startClientAndProxy(PortFactory.findFreePort()); mockServer = ClientAndServer.startClientAndServer(MOCKSERVER_PORT); } }
Example 12
Source File: AppVariables.java From MyBox with Apache License 2.0 | 5 votes |
public static void initAppVaribles() { try { userConfigValues = new HashMap<>(); systemConfigValues = new HashMap<>(); getBundle(); getPdfMem(); openStageInNewWindow = AppVariables.getUserConfigBoolean("OpenStageInNewWindow", false); restoreStagesSize = AppVariables.getUserConfigBoolean("RestoreStagesSize", true); sceneFontSize = AppVariables.getUserConfigInt("SceneFontSize", 15); fileRecentNumber = AppVariables.getUserConfigInt("FileRecentNumber", 15); iconSize = AppVariables.getUserConfigInt("IconSize", 20); ControlColor = ControlStyle.getConfigColorStyle(); controlDisplayText = AppVariables.getUserConfigBoolean("ControlDisplayText", false); ImagePopCooridnate = AppVariables.getUserConfigBoolean("ImagePopCooridnate", false); disableHiDPI = DerbyFailAsked = false; DaoDeMapVersion = AppVariables.getUserConfigValue("DaoDeMapVersion", "1.4.15"); DaoDeMapWebKey = AppVariables.getUserConfigValue("DaoDeMapWebKey", "06b9e078a51325a843dfefd57ffd876c"); DaoDeMapWebServiceKey = AppVariables.getUserConfigValue("DaoDeMapWebServiceKey", "d7444d9a7fae01fa850236d909ad4450"); lastError = null; if (defaultSSLSocketFactory == null) { defaultSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); defaultHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier(); } } catch (Exception e) { logger.error(e.toString()); } }
Example 13
Source File: SourcePage.java From Beedio with GNU General Public License v2.0 | 5 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); size = getArguments().getLong("size"); page = getArguments().getString("page"); defaultSSLSF = HttpsURLConnection.getDefaultSSLSocketFactory(); }
Example 14
Source File: ConfigurationModuleSSLVerifier.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void init(Configuration config) throws TechnicalConnectorException { LOG.debug("Initializing ConfigurationModule " + this.getClass().getName()); LOG.warn("Activating bypass: SSL verifcation. DO NOT USE THIS IN PRODUCTION."); TrustManager[] trustAllCerts = new TrustManager[]{new ConfigurationModuleSSLVerifier.ConnectorTrustManager()}; try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init((KeyManager[])null, trustAllCerts, new SecureRandom()); this.oldSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Exception var4) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()}); } }
Example 15
Source File: ConfigurationModuleSSLVerifier.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void init(Configuration config) throws TechnicalConnectorException { LOG.debug("Initializing ConfigurationModule " + this.getClass().getName()); LOG.warn("Activating bypass: SSL verifcation. DO NOT USE THIS IN PRODUCTION."); TrustManager[] trustAllCerts = new TrustManager[]{new ConfigurationModuleSSLVerifier.ConnectorTrustManager()}; try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init((KeyManager[])null, trustAllCerts, new SecureRandom()); this.oldSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Exception var4) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()}); } }
Example 16
Source File: ConfigurationModuleSSLVerifier.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void init(Configuration config) throws TechnicalConnectorException { LOG.debug("Initializing ConfigurationModule " + this.getClass().getName()); LOG.warn("Activating bypass: SSL verifcation. DO NOT USE THIS IN PRODUCTION."); TrustManager[] trustAllCerts = new TrustManager[]{new ConfigurationModuleSSLVerifier.ConnectorTrustManager()}; try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init((KeyManager[])null, trustAllCerts, new SecureRandom()); this.oldSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Exception var4) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_GENERAL, var4, new Object[]{var4.getMessage()}); } }
Example 17
Source File: App.java From droidddle with Apache License 2.0 | 4 votes |
public static void initialize(Context context) { try { synchronized (lock) { if (initialized) { return; } initialized = true; // GMS Conscrypt is already initialized, from outside ion. Leave it alone. if (Security.getProvider(GMS_PROVIDER) != null) { success = true; return; } SSLContext originalDefaultContext = SSLContext.getDefault(); SSLSocketFactory originalDefaultSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); try { Class<?> providerInstaller = Class.forName("com.google.android.gms.security.ProviderInstaller"); Method mInsertProvider = providerInstaller.getDeclaredMethod("installIfNeeded", Context.class); mInsertProvider.invoke(null, context); } catch (Throwable ignored) { Context gms = context .createPackageContext("com.google.android.gms", Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); gms.getClassLoader().loadClass("com.google.android.gms.common.security.ProviderInstallerImpl") .getMethod("insertProvider", Context.class).invoke(null, context); } Provider[] providers = Security.getProviders(); Provider provider = Security.getProvider(GMS_PROVIDER); Security.removeProvider(GMS_PROVIDER); Security.insertProviderAt(provider, providers.length); SSLContext.setDefault(originalDefaultContext); HttpsURLConnection.setDefaultSSLSocketFactory(originalDefaultSSLSocketFactory); success = true; // try { // SSLContext sslContext = null; // try { // sslContext = SSLContext.getInstance("TLS", GMS_PROVIDER); // } // catch (Exception e) { // } // if (sslContext == null) // sslContext = SSLContext.getInstance("TLS"); // sslContext.init(null, null, null); // } // catch (Exception e) { // } } } catch (Exception e) { } }
Example 18
Source File: SSLSocketFactory.java From Popeens-DSub with GNU General Public License v3.0 | 4 votes |
private SSLSocketFactory() { super(); this.socketfactory = HttpsURLConnection.getDefaultSSLSocketFactory(); this.hostnameVerifier = null; this.nameResolver = null; }
Example 19
Source File: RestServerEndpointITCase.java From flink with Apache License 2.0 | 4 votes |
@Before public void setup() throws Exception { config.setString(WebOptions.UPLOAD_DIR, temporaryFolder.newFolder().getCanonicalPath()); defaultSSLContext = SSLContext.getDefault(); defaultSSLSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); final SSLContext sslClientContext = SSLUtils.createRestSSLContext(config, true); if (sslClientContext != null) { SSLContext.setDefault(sslClientContext); HttpsURLConnection.setDefaultSSLSocketFactory(sslClientContext.getSocketFactory()); } RestServerEndpointConfiguration serverConfig = RestServerEndpointConfiguration.fromConfiguration(config); RestClientConfiguration clientConfig = RestClientConfiguration.fromConfiguration(config); RestfulGateway mockRestfulGateway = mock(RestfulGateway.class); final GatewayRetriever<RestfulGateway> mockGatewayRetriever = () -> CompletableFuture.completedFuture(mockRestfulGateway); testHandler = new TestHandler( mockGatewayRetriever, RpcUtils.INF_TIMEOUT); TestVersionHandler testVersionHandler = new TestVersionHandler( mockGatewayRetriever, RpcUtils.INF_TIMEOUT); TestVersionSelectionHandler1 testVersionSelectionHandler1 = new TestVersionSelectionHandler1( mockGatewayRetriever, RpcUtils.INF_TIMEOUT); TestVersionSelectionHandler2 testVersionSelectionHandler2 = new TestVersionSelectionHandler2( mockGatewayRetriever, RpcUtils.INF_TIMEOUT); testUploadHandler = new TestUploadHandler( mockGatewayRetriever, RpcUtils.INF_TIMEOUT); final StaticFileServerHandler<RestfulGateway> staticFileServerHandler = new StaticFileServerHandler<>( mockGatewayRetriever, RpcUtils.INF_TIMEOUT, temporaryFolder.getRoot()); final List<Tuple2<RestHandlerSpecification, ChannelInboundHandler>> handlers = Arrays.asList( Tuple2.of(new TestHeaders(), testHandler), Tuple2.of(TestUploadHeaders.INSTANCE, testUploadHandler), Tuple2.of(testVersionHandler.getMessageHeaders(), testVersionHandler), Tuple2.of(testVersionSelectionHandler1.getMessageHeaders(), testVersionSelectionHandler1), Tuple2.of(testVersionSelectionHandler2.getMessageHeaders(), testVersionSelectionHandler2), Tuple2.of(WebContentHandlerSpecification.getInstance(), staticFileServerHandler)); serverEndpoint = new TestRestServerEndpoint(serverConfig, handlers); restClient = new TestRestClient(clientConfig); serverEndpoint.start(); serverAddress = serverEndpoint.getServerAddress(); }
Example 20
Source File: NoSSLv3SocketFactory.java From Pix-Art-Messenger with GNU General Public License v3.0 | 4 votes |
public NoSSLv3SocketFactory() { this.delegate = HttpsURLConnection.getDefaultSSLSocketFactory(); }