This is an automated email from the ASF dual-hosted git repository.
zabetak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 80c4ebc Remove the insecure, unused `TrustAllSslSocketFactory` class
(intrigus-lgtm)
80c4ebc is described below
commit 80c4ebc17af928e2f4ee3a475abf9c62bf528faa
Author: intrigus-lgtm <[email protected]>
AuthorDate: Thu Dec 24 23:58:23 2020 +0100
Remove the insecure, unused `TrustAllSslSocketFactory` class (intrigus-lgtm)
Following history, this leads us to
https://github.com/apache/calcite/commit/33013ac160c9aa5e5a2b4373976fc5109f622197#diff-1f23cb4c9c91d3536d23f20dfe702e6d0f4068418283c573cadad05ab32f4a3b
and
https://github.com/julianhyde/optiq-splunk/commit/262688f1bf65f4e884dc3496e13c6bb992ff5701#diff-609118c1f9bfb010bcd846c0a85b9c637190a4ccd83d19bcde427c7ff6a81d11
The only user was `HttpUtils`
https://github.com/apache/calcite/commit/33013ac160c9aa5e5a2b4373976fc5109f622197#diff-6c6ed01845b745f36f3d925b8aab55d18e12d6c47c7261793383e3dde370fdd5R46
and the insecure code in `HttpUtils` has been removed in [CALCITE-4298].
TrustAllSslSocketFactory was not removed along with CALCITE-4298 cause
it could be used by others for testing purposes. However, given that there
is no security warning and it is not used by calcite itself its better to
remove it entirely.
Close apache/calcite#2304
---
.../calcite/runtime/TrustAllSslSocketFactory.java | 136 ---------------------
1 file changed, 136 deletions(-)
diff --git
a/core/src/main/java/org/apache/calcite/runtime/TrustAllSslSocketFactory.java
b/core/src/main/java/org/apache/calcite/runtime/TrustAllSslSocketFactory.java
deleted file mode 100644
index 80b828d..0000000
---
a/core/src/main/java/org/apache/calcite/runtime/TrustAllSslSocketFactory.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.runtime;
-
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.security.SecureRandom;
-import java.security.cert.X509Certificate;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import static org.apache.calcite.linq4j.Nullness.castNonNull;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * Socket factory that trusts all SSL connections.
- */
-@SuppressWarnings("CatchAndPrintStackTrace")
-public class TrustAllSslSocketFactory extends SocketFactoryImpl {
- private static final TrustAllSslSocketFactory DEFAULT =
- new TrustAllSslSocketFactory();
-
- private final SSLSocketFactory sslSocketFactory;
-
- protected TrustAllSslSocketFactory() {
- TrustManager[] trustAllCerts = {new DummyTrustManager()};
- SSLSocketFactory factory = null;
- try {
- SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, trustAllCerts, new SecureRandom());
- factory = sc.getSocketFactory();
- } catch (Exception e) {
- e.printStackTrace();
- }
- this.sslSocketFactory = requireNonNull(factory, "sslSocketFactory");
- }
-
- @Override public Socket createSocket() throws IOException {
- return applySettings(sslSocketFactory.createSocket());
- }
-
- @Override public Socket createSocket(InetAddress host, int port)
- throws IOException {
- return applySettings(sslSocketFactory.createSocket(host, port));
- }
-
- @Override public Socket createSocket(InetAddress address, int port,
- InetAddress localAddress, int localPort) throws IOException {
- return applySettings(
- sslSocketFactory.createSocket(
- address, port, localAddress, localPort));
- }
-
- @Override public Socket createSocket(String host, int port)
- throws IOException {
- return applySettings(sslSocketFactory.createSocket(host, port));
- }
-
- @Override public Socket createSocket(String host, int port,
- InetAddress localHost, int localPort) throws IOException {
- return applySettings(
- sslSocketFactory.createSocket(host, port, localHost, localPort));
- }
-
- /**
- * Returns a copy of the environment's default socket factory.
- *
- * @see javax.net.SocketFactory#getDefault()
- */
- public static TrustAllSslSocketFactory getDefault() {
- return DEFAULT;
- }
-
- public static SSLSocketFactory getDefaultSSLSocketFactory() {
- return DEFAULT.sslSocketFactory;
- }
-
- /**
- * Creates an "accept-all" SSLSocketFactory - ssl sockets will accept ANY
- * certificate sent to them - thus effectively just securing the
- * communications. This could be set in a HttpsURLConnection using
- * HttpsURLConnection.setSSLSocketFactory(.....)
- *
- * @return SSLSocketFactory
- */
- public static @Nullable SSLSocketFactory createSSLSocketFactory() {
- SSLSocketFactory sslsocketfactory = null;
- TrustManager[] trustAllCerts = {new DummyTrustManager()};
- try {
- SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, trustAllCerts, new java.security.SecureRandom());
- sslsocketfactory = sc.getSocketFactory();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return sslsocketfactory;
- }
-
- /** Implementation of {@link X509TrustManager} that trusts all
- * certificates. */
- private static class DummyTrustManager implements X509TrustManager {
- @Override public X509Certificate[] getAcceptedIssuers() {
- return castNonNull(null);
- }
-
- @Override public void checkClientTrusted(
- X509Certificate[] certs,
- String authType) {
- }
-
- @Override public void checkServerTrusted(
- X509Certificate[] certs,
- String authType) {
- }
- }
-}