maulin-vasavada commented on a change in pull request #1027: URL: https://github.com/apache/cassandra/pull/1027#discussion_r690075874
########## File path: src/java/org/apache/cassandra/security/ISslContextFactory.java ########## @@ -0,0 +1,118 @@ +/* + * 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.cassandra.security; + +import java.util.List; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLException; + +import io.netty.handler.ssl.CipherSuiteFilter; +import io.netty.handler.ssl.SslContext; + +/** + * The purpose of this interface is to provide pluggable mechanism for creating custom JSSE and Netty SSLContext + * objects. Please use the Cassandra configuration key {@code ssl_context_factory} as part of {@code + * client_encryption_options}/{@code server_encryption_options} and provide a custom class-name implementing this + * interface with parameters to be used to plugin a your own way to load the SSLContext. + * + * Implementation of this interface must have a constructor with argument of type {@code Map<String,Object>} to allow + * custom parameters, needed by the implementation, to be passed from the yaml configuration. Common SSL + * configurations like {@code protocol, algorithm, cipher_suites, accepted_protocols, require_client_auth, + * require_endpoint_verification, enabled, optional} will also be passed to that map by Cassanddra. + * + * Since on top of Netty, Cassandra is internally using JSSE SSLContext also for certain use-cases- this interface + * has methods for both. + * + * Below is an example of how to configure a custom implementation with parameters + * <pre> + * ssl_context_factory: + * class_name: org.apache.cassandra.security.YourSslContextFactoryImpl + * parameters: + * key1: "value1" + * key2: "value2" + * key3: "value3" + * </pre> + */ +public interface ISslContextFactory +{ + /** + * Creates JSSE SSLContext. + * + * @param buildTruststore {@code true} if the caller requires Truststore; {@code false} otherwise + * @return JSSE's {@link SSLContext} + * @throws SSLException in case the Ssl Context creation fails for some reason + */ + SSLContext createJSSESslContext(boolean buildTruststore) throws SSLException; + + /** + * Creates Netty's SslContext object. + * + * @param buildTruststore {@code true} if the caller requires Truststore; {@code false} otherwise + * @param socketType {@link SocketType} for Netty's Inbound or Outbound channels + * @param useOpenSsl {@code true} if openSsl is enabled;{@code false} otherwise Review comment: @jonmeredith Out of the above three - I moved the useOpenSsl flag determination to the AbstractSslContextFactory implementation. Please review. Now will work on the other two. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

