diff --git a/client/main.go b/client/main.go index b60974f..8d5e05d 100644 --- a/client/main.go +++ b/client/main.go @@ -2,7 +2,9 @@ package main import ( "context" + "crypto/tls" "log" + "net/http" pbcloudevents "github.com/cloudevents/sdk-go/binding/format/protobuf/v2" cloudevents "github.com/cloudevents/sdk-go/v2" @@ -18,6 +20,13 @@ func main() { log.Fatalf("failed to create protocol: %s", err.Error()) } + // Load the certificate + p.Client.Transport = &http.Transport{ + TLSClientConfig: &tls.Config{ + Certificates: []tls.Certificate{loadCertificate()}, + }, + } + c, err := cloudevents.NewClient(p, cloudevents.WithTimeNow(), cloudevents.WithUUIDs()) if err != nil { log.Fatalf("failed to create client, %v", err) @@ -44,3 +53,11 @@ func main() { } } } + +func loadCertificate() tls.Certificate { + cert, err := tls.LoadX509KeyPair("path/to/certificate.crt", "path/to/private.key") + if err != nil { + log.Fatalf("failed to load certificate: %v", err) + } + return cert +}