#!/bin/bash # Copyright The Shipwright Contributors # # SPDX-License-Identifier: Apache-2.0 set -euo pipefail if ! hash jq >/dev/null 2>&1 ; then echo "[ERROR] jq is not installed" exit 1 fi if ! hash openssl >/dev/null 2>&1 ; then echo "[ERROR] openssl is not installed" exit 1 fi echo "[INFO] Generating key and signing request for Shipwright Build Webhook" cat </tmp/csr.conf [req] req_extensions = v3_req distinguished_name = req_distinguished_name [req_distinguished_name] [ v3_req ] basicConstraints = CA:FALSE keyUsage = digitalSignature, keyEncipherment extendedKeyUsage = serverAuth subjectAltName = @alt_names [alt_names] DNS.1 = shp-build-webhook DNS.2 = shp-build-webhook.shipwright-build DNS.3 = shp-build-webhook.shipwright-build.svc DNS.4 = shp-build-webhook.shipwright-build.svc.cluster.local EOF openssl genrsa -out /tmp/server-key.pem 2048 openssl req -new -days 365 -key /tmp/server-key.pem -subj "/O=system:nodes/CN=system:node:shp-build-webhook.shipwright-build.svc.cluster.local" -out /tmp/server.csr -config /tmp/csr.conf echo "[INFO] Deleting previous CertificateSigningRequest" kubectl delete csr shipwright-build-webhook-csr --ignore-not-found echo "[INFO] Create a CertificateSigningRequest" cat <