github.com/weaveworks/common@v0.0.0-20230728070032-dd9e68f319d5/server/certs/genCerts.sh (about)

     1  #!/usr/bin/env bash
     2  # From https://github.com/joe-elliott/cert-exporter/blob/69d3d7230378325a1de4fa313432d3d6ced4a518/test/files/genCerts.sh
     3  certFolder=$1
     4  days=$2
     5  
     6  pushd "$certFolder"
     7  
     8  # keys
     9  openssl genrsa -out root.key
    10  openssl genrsa -out client.key
    11  openssl genrsa -out server.key
    12  
    13  # root cert
    14  openssl req -x509 -new -nodes -key root.key -subj "/C=US/ST=KY/O=Org/CN=root" -sha256 -days "$days" -out root.crt
    15  
    16  # csrs
    17  openssl req -new -sha256 -key client.key -subj "/C=US/ST=KY/O=Org/CN=client" -out client.csr
    18  openssl req -new -sha256 -key server.key -subj "/C=US/ST=KY/O=Org/CN=localhost" -out server.csr
    19  
    20  openssl x509 -req -in client.csr -CA root.crt -CAkey root.key -CAcreateserial -out client.crt -days "$days" -sha256
    21  openssl x509 -req -in server.csr -CA root.crt -CAkey root.key -CAcreateserial -out server.crt -days "$days" -sha256
    22  
    23  popd