001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license 003 * agreements. See the NOTICE file distributed with this work for additional information regarding 004 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 005 * "License"); you may not use this file except in compliance with the License. You may obtain a 006 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 007 * law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 008 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 009 * for the specific language governing permissions and limitations under the License. 010 */ 011package org.apache.hadoop.hbase; 012 013import java.io.IOException; 014import java.net.ServerSocket; 015import java.net.Socket; 016import java.util.ArrayList; 017import javax.net.ssl.SSLSocket; 018import javax.net.ssl.SSLSocketFactory; 019import javax.rmi.ssl.SslRMIServerSocketFactory; 020import org.apache.yetus.audience.InterfaceAudience; 021 022/** 023 * Avoid SSL V3.0 "Poodle" Vulnerability - CVE-2014-3566 024 */ 025@InterfaceAudience.Private 026public class SslRMIServerSocketFactorySecure extends SslRMIServerSocketFactory { 027 // If you add more constructors, you may have to change the rest of this implementation, 028 // which assumes an empty constructor, i.e. there are no specially enabled protocols or 029 // cipher suites on this RMI factory nor a provided SSLContext 030 public SslRMIServerSocketFactorySecure() { 031 super(); 032 } 033 034 @Override 035 public ServerSocket createServerSocket(int port) throws IOException { 036 return new ServerSocket(port) { 037 @Override 038 public Socket accept() throws IOException { 039 Socket socket = super.accept(); 040 SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); 041 SSLSocket sslSocket = 042 (SSLSocket) sslSocketFactory.createSocket(socket, 043 socket.getInetAddress().getHostName(), socket.getPort(), true); 044 sslSocket.setUseClientMode(false); 045 sslSocket.setNeedClientAuth(false); 046 047 ArrayList<String> secureProtocols = new ArrayList<>(); 048 for (String p : sslSocket.getEnabledProtocols()) { 049 if (!p.contains("SSLv3")) { 050 secureProtocols.add(p); 051 } 052 } 053 sslSocket.setEnabledProtocols(secureProtocols.toArray(new String[secureProtocols.size()])); 054 055 return sslSocket; 056 } 057 }; 058 } 059}