Skip to content

Commit

Permalink
Accept MacOS SSL error message.
Browse files Browse the repository at this point in the history
The error messages for invalid certificates is slightly different on
Linux and MacOS. We should accept both.

Once this issue is fixed: golang/go#52010
we can just compare the error to the canonical UnknownAuthorityError.
  • Loading branch information
josephburnett authored and Joseph Burnett committed Sep 14, 2022
1 parent e1a5c68 commit 58314be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion helpers/certificate/x509_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"crypto/x509"
"net"
"net/http"
"regexp"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -61,5 +62,7 @@ func TestCertificate(t *testing.T) {

_, err = client.Do(req)
assert.Error(t, err)
assert.Contains(t, err.Error(), "certificate signed by unknown authority")
// Error messages provided by Linux and MacOS respectively.
const want = "certificate signed by unknown authority|certificate is not trusted"
assert.Regexp(t, regexp.MustCompile(want), err.Error())
}
5 changes: 4 additions & 1 deletion network/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/url"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -295,7 +296,9 @@ func TestClientInvalidSSL(t *testing.T) {
nil,
)
assert.Equal(t, -1, statusCode, statusText)
assert.Contains(t, statusText, "certificate signed by unknown authority")
// Error messages provided by Linux and MacOS respectively.
const want = "certificate signed by unknown authority|certificate is not trusted"
assert.Regexp(t, regexp.MustCompile(want), statusText)
}

func TestClientTLSCAFile(t *testing.T) {
Expand Down

0 comments on commit 58314be

Please sign in to comment.