Triggers now support both HTTP
and HTTPS
connection by adding some configurations to eventlistener.
- Create Root Key
openssl genrsa -des3 -out rootCA.key 4096
- Create and self sign the Root Certificate
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.crt
- Create the certificate key
openssl genrsa -out tls.key 2048
- Create the signing (csr)
-
The CSR is where you specify the details for the certificate you want to generate. This request will be processed by the owner of the root key to generate the certificate.
-
Important: While creating the csr it is important to specify the
Common Name
providing the IP address or domain name for the service, otherwise the certificate cannot be verified.openssl req -new -key tls.key -out tls.csr
- Generate the certificate using the tls csr and key along with the CA Root key
openssl x509 -req -in tls.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out tls.crt -days 500 -sha256
Once you have the certs created following the steps above, you can create a Kubernetes secret that includes those certificates:
kubectl create secret generic tls-secret-key --from-file=tls.crt --from-file=tls.key
Once you have the certs, and secrets configured by following the steps in the prerequisite section, you can configure the EventListener to listen for TLS connections
-
To create the TLS connection for EventListener and all related resources, run:
kubectl apply -f .
-
Test by sending the sample payload.
curl -v \ -H 'X-GitHub-Event: pull_request' \ -H 'X-Hub-Signature: sha1=ba0cdc263b3492a74b601d240c27efe81c4720cb' \ -H 'Content-Type: application/json' \ -d '{"action": "opened", "pull_request":{"head":{"sha": "28911bbb5a3e2ea034daf1f6be0a822d50e31e73"}},"repository":{"clone_url": "https://github.com/tektoncd/triggers.git"}}' \ https://<el-address> --cacert rootCA.crt --key client.key --cert client.crt
The response status code should be
202 Accepted
HMAC
tool used to create X-Hub-Signature.In
HMAC
string
is the body payload ex:{"action": "opened", "pull_request":{"head":{"sha": "28911bbb5a3e2ea034daf1f6be0a822d50e31e73"}},"repository":{"clone_url": "https://github.com/tektoncd/triggers.git"}}
andsecretKey
is the given secretToken ex:1234567
. -
You should see a new TaskRun that got created:
kubectl get taskruns | grep tls-run-