Skip to content

Commit 2c4df5c

Browse files
authored
Merge pull request #383 from guillaumerose/main
2 parents 1886c88 + 5db7fa1 commit 2c4df5c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/cmd/tknpac/bootstrap/route.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package bootstrap
22

33
import (
44
"context"
5+
"crypto/x509"
6+
"errors"
57
"fmt"
68
"net/http"
7-
"strings"
89

910
"github.com/openshift-pipelines/pipelines-as-code/pkg/params"
1011
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -49,11 +50,15 @@ func detectSelfSignedCertificate(ctx context.Context, url string) string {
4950

5051
client := http.Client{}
5152
resp, err := client.Do(req)
52-
if err != nil && strings.Contains(err.Error(), "x509: certificate is not valid") {
53+
if err != nil && isTLSError(err) {
5354
return "⚠️ your eventlistenner route is using self signed certificate\n⚠️ make sure you allow connecting to self signed url in your github app setting."
5455
} else if err != nil {
5556
return fmt.Sprintf("⚠️ could not connect to the route %s, make sure the eventlistenner is running", url)
5657
}
5758
resp.Body.Close()
5859
return ""
5960
}
61+
62+
func isTLSError(err error) bool {
63+
return errors.As(err, &x509.UnknownAuthorityError{}) || errors.As(err, &x509.CertificateInvalidError{})
64+
}

0 commit comments

Comments
 (0)