You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2018/11/01 10:17:07 UTC

[GitHub] azagrebin commented on a change in pull request #6967: [FLINK-10628][E2E][SSL] Enable mutual REST SSL auth in e2e tests

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_r229995108
 
 

 ##########
 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
 
 Review comment:
   keystore is converted into the PEM format to use it with curl, I will add a comment for that

----------------------------------------------------------------
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


With regards,
Apache Git Services