flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-10628) Add end-to-end test for REST communication encryption
Date Thu, 01 Nov 2018 10:20:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-10628?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16671414#comment-16671414
] 

ASF GitHub Bot commented on FLINK-10628:
----------------------------------------

azagrebin commented on a change in pull request #6967: [FLINK-10628][E2E][SSL] Enable mutual
REST SSL auth in e2e tests
URL: https://github.com/apache/flink/pull/6967#discussion_r229995637
 
 

 ##########
 File path: flink-end-to-end-tests/test-scripts/common_ssl.sh
 ##########
 @@ -0,0 +1,98 @@
+#!/usr/bin/env bash
+
+################################################################################
+# 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.
+################################################################################
+
+function _set_conf_ssl_helper {
+    local type=$1 # 'internal' or external 'rest'
+    local ssl_dir="${TEST_DATA_DIR}/ssl/${type}"
+    local password="${type}.password"
+
+    if [ "${type}" != "internal" ] && [ "${type}" != "rest" ]; then
+        echo "Unknown type of ssl connectivity: ${type}. It can be either 'internal' or external
'rest'"
+        exit 1
+    fi
+
+    # clean up the dir that will be used for SSL certificates and trust stores
+    if [ -e "${ssl_dir}" ]; then
+       echo "File ${ssl_dir} exists. Deleting it..."
+       rm -rf "${ssl_dir}"
+    fi
+    mkdir -p "${ssl_dir}"
+
+    SANSTRING="dns:${NODENAME}"
+    for NODEIP in $(get_node_ip) ; do
+        SANSTRING="${SANSTRING},ip:${NODEIP}"
+    done
+
+    echo "Using SAN ${SANSTRING}"
+
+    # create certificates
+    keytool -genkeypair -alias ca -keystore "${ssl_dir}/ca.keystore" -dname "CN=Sample CA"
-storepass ${password} -keypass ${password} -keyalg RSA -ext bc=ca:true -storetype PKCS12
+    keytool -keystore "${ssl_dir}/ca.keystore" -storepass ${password} -alias ca -exportcert
> "${ssl_dir}/ca.cer"
+    keytool -importcert -keystore "${ssl_dir}/ca.truststore" -alias ca -storepass ${password}
-noprompt -file "${ssl_dir}/ca.cer"
+
+    keytool -genkeypair -alias node -keystore "${ssl_dir}/node.keystore" -dname "CN=${NODENAME}"
-ext SAN=${SANSTRING} -storepass ${password} -keypass ${password} -keyalg RSA -storetype PKCS12
+    keytool -certreq -keystore "${ssl_dir}/node.keystore" -storepass ${password} -alias node
-file "${ssl_dir}/node.csr"
+    keytool -gencert -keystore "${ssl_dir}/ca.keystore" -storepass ${password} -alias ca
-ext SAN=${SANSTRING} -infile "${ssl_dir}/node.csr" -outfile "${ssl_dir}/node.cer"
+    keytool -importcert -keystore "${ssl_dir}/node.keystore" -storepass ${password} -file
"${ssl_dir}/ca.cer" -alias ca -noprompt
+    keytool -importcert -keystore "${ssl_dir}/node.keystore" -storepass ${password} -file
"${ssl_dir}/node.cer" -alias node -noprompt
+
+    openssl pkcs12 -passin pass:${password} -in "${ssl_dir}/node.keystore" -passout pass:
-out "${ssl_dir}/node.pem" -nodes
+
+    # adapt config
+    # (here we rely on security.ssl.enabled enabling SSL for all components and internal
as well as
+    # external communication channels)
+    set_conf security.ssl.${type}.enabled true
+    set_conf security.ssl.${type}.keystore ${ssl_dir}/node.keystore
+    set_conf security.ssl.${type}.keystore-password ${password}
+    set_conf security.ssl.${type}.key-password ${password}
+    set_conf security.ssl.${type}.truststore ${ssl_dir}/ca.truststore
+    set_conf security.ssl.${type}.truststore-password ${password}
+}
+
+function set_conf_internal_ssl {
+    _set_conf_ssl_helper "internal"
+}
+
+function set_conf_mutual_rest_ssl {
+    local auth="${1:-server}" # only 'server' or 'mutual'
+    local mutual="false"
+    local ssl_dir="${TEST_DATA_DIR}/ssl/rest"
+    if [ "${auth}" == "mutual" ]; then
+        CURL_SSL_ARGS="${CURL_SSL_ARGS} --cert ${ssl_dir}/node.pem"
+        mutual="true";
+    fi
+    echo "Mutual ssl auth: ${mutual}"
+    set_conf security.ssl.rest.authentication-enabled ${mutual}
+}
+
+function set_conf_rest_ssl {
+    local auth="${1:-server}" # only 'server' or 'mutual'
+    local ssl_dir="${TEST_DATA_DIR}/ssl/rest"
+    _set_conf_ssl_helper "rest"
+    set_conf_mutual_rest_ssl ${auth}
+    REST_PROTOCOL="https"
+    CURL_SSL_ARGS="${CURL_SSL_ARGS} --cacert ${ssl_dir}/node.pem"
 
 Review comment:
   ok, I will source `common_ssl.sh` in `common.sh` close to the modified vars and add a comment.
I still want to have SSL modularised to reduce the huge `common.sh` file.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Add end-to-end test for REST communication encryption
> -----------------------------------------------------
>
>                 Key: FLINK-10628
>                 URL: https://issues.apache.org/jira/browse/FLINK-10628
>             Project: Flink
>          Issue Type: Sub-task
>          Components: REST
>    Affects Versions: 1.7.0
>            Reporter: Till Rohrmann
>            Assignee: Andrey Zagrebin
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.7.0
>
>
> With FLINK-10371 we added support for mutual authentication for the REST communication.
We should adapt one of the existing end-to-end tests to require this feature for the REST
communication.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message