github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/tests/e2e/scripts/generate_cert.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright 2019 The KubeEdge Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #    http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  sudo apt-get install openssl -y
    18  
    19  #Required
    20  commonname=kubeedge
    21  
    22  #Change to your company details
    23  country=IN
    24  state=Karnataka
    25  locality=Bangalore
    26  organization=Htipl
    27  organizationalunit=IT
    28  email=administrator@htipl.com
    29  
    30  #Optional
    31  password=root
    32  
    33  echo "Generating key request for kubeedge"
    34  
    35  # Generete Root Key
    36  sudo openssl genrsa -des3 -passout pass:$password -out rootCA.key 4096
    37  # Generate Root Certificate
    38  sudo openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.crt -passin pass:$password \
    39      -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
    40  # Generate Key
    41  sudo openssl genrsa -out kubeedge.key 2048
    42  # Generate csr, Fill required details after running the command
    43  sudo openssl req -new -key kubeedge.key -out kubeedge.csr -passin pass:$password \
    44      -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
    45  # Generate Certificate
    46  sudo openssl x509 -req -in kubeedge.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out kubeedge.crt -days 500 -sha256 -passin pass:$password
    47  
    48  echo "---------------------------------------------"
    49  echo "-----Certificate Generation is Completed-----"
    50  echo "---------------------------------------------"
    51  
    52  #Generate temparory folder in Edge and Cloud folders to copy certs
    53  sudo mkdir -p $GOPATH/src/github.com/kubeedge/kubeedge/edge/tmp
    54  sudo mkdir -p $GOPATH/src/github.com/kubeedge/kubeedge/cloud/tmp
    55  #Copy the generated certs to respective paths
    56  mkdir -p /tmp/edgecore
    57  mkdir -p /tmp/cloudcore
    58  mkdir -p /tmp/edgesite
    59  
    60  sudo cp -r rootCA.crt rootCA.key kubeedge.crt kubeedge.key /tmp/edgecore
    61  sudo cp -r rootCA.crt rootCA.key kubeedge.crt kubeedge.key /tmp/cloudcore
    62  
    63  echo "-----Certificate are Copied to Edge and Cloud Nodes-----"