Skip to content

Commit 2d85357

Browse files
authored
Merge pull request #259 from hashicorp/bendbennett/issues-256
Bump minimum expected Go version to 1.18
2 parents cb9f836 + a29accc commit 2d85357

File tree

7 files changed

+8
-88
lines changed

7 files changed

+8
-88
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
strategy:
2525
matrix:
26-
go-version: [ '1.18', '1.17' ]
26+
go-version: [ '1.19', '1.18' ]
2727

2828
steps:
2929

.go-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.17.11
1+
1.18.5

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/hashicorp/terraform-provider-tls
22

3-
go 1.17
3+
go 1.18
44

55
require (
66
github.com/elazarl/goproxy v0.0.0-20220529153421-8ea89ba92021

go.sum

Lines changed: 0 additions & 65 deletions
Large diffs are not rendered by default.

internal/provider/data_source_certificate_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"testing"
88

99
r "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
10+
1011
"github.com/hashicorp/terraform-provider-tls/internal/provider/fixtures"
1112
tu "github.com/hashicorp/terraform-provider-tls/internal/provider/testutils"
1213
)
@@ -170,7 +171,7 @@ func TestAccDataSourceCertificate_BadSSL(t *testing.T) {
170171
url = "https://untrusted-root.badssl.com/"
171172
}
172173
`,
173-
ExpectError: regexp.MustCompile(`certificate signed by[\s]*unknown[\s]*authority`),
174+
ExpectError: regexp.MustCompile(`(certificate is not trusted|certificate signed by[\s]*unknown[\s]*authority)`),
174175
},
175176
{
176177
Config: `
@@ -197,7 +198,7 @@ func TestAccDataSourceCertificate_BadSSL(t *testing.T) {
197198
r.TestCheckResourceAttr("data.tls_certificate.test", "certificates.1.signature_algorithm", "SHA256-RSA"),
198199
r.TestCheckResourceAttr("data.tls_certificate.test", "certificates.1.public_key_algorithm", "RSA"),
199200
r.TestCheckResourceAttr("data.tls_certificate.test", "certificates.1.is_ca", "false"),
200-
r.TestCheckResourceAttr("data.tls_certificate.test", "certificates.1.sha1_fingerprint", "dfa540cf03c6b61a0d78e6c61dc6ea9823245d4f"),
201+
r.TestCheckResourceAttr("data.tls_certificate.test", "certificates.1.sha1_fingerprint", "03e9ff8bdfda8ee5ac1f97f9567ee49a464caa0c"),
201202
),
202203
},
203204
},

internal/provider/resource_locally_signed_cert_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
r "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
14+
1415
"github.com/hashicorp/terraform-provider-tls/internal/provider/fixtures"
1516
tu "github.com/hashicorp/terraform-provider-tls/internal/provider/testutils"
1617
)

internal/provider/testutils/test_check_func.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"crypto/x509"
66
"crypto/x509/pkix"
77
"encoding/pem"
8-
"errors"
98
"fmt"
109
"net"
1110
"net/url"
@@ -183,26 +182,10 @@ func TestCheckPEMCertificateNoAuthorityKeyID(name, key string) r.TestCheckFunc {
183182

184183
func TestCheckPEMCertificateAgainstPEMRootCA(name, key string, rootCA []byte) r.TestCheckFunc {
185184
return TestCheckPEMCertificateWith(name, key, func(crt *x509.Certificate) error {
186-
// Certificate verification must fail if no CA Cert Pool is provided
187-
_, err := crt.Verify(x509.VerifyOptions{})
188-
if err == nil {
189-
return fmt.Errorf("incorrectly verified certificate")
190-
} else if !errors.Is(err, x509.UnknownAuthorityError{Cert: crt}) {
191-
return fmt.Errorf("incorrect verify error: expected UnknownAuthorityError, got %v", err)
192-
}
193-
194-
// Certificate verification must fail if an empty CA Cert Pool is provided
195-
_, err = crt.Verify(x509.VerifyOptions{Roots: x509.NewCertPool()})
196-
if err == nil {
197-
return fmt.Errorf("incorrectly verified certificate")
198-
} else if !errors.Is(err, x509.UnknownAuthorityError{Cert: crt}) {
199-
return fmt.Errorf("incorrect verify error: expected UnknownAuthorityError, got %v", err)
200-
}
201-
202185
// Certification verification must succeed now that we are providing the correct CA Cert Pool
203186
certPool := x509.NewCertPool()
204187
certPool.AppendCertsFromPEM(rootCA)
205-
if _, err = crt.Verify(x509.VerifyOptions{Roots: certPool}); err != nil {
188+
if _, err := crt.Verify(x509.VerifyOptions{Roots: certPool}); err != nil {
206189
return fmt.Errorf("verify failed: %s", err)
207190
}
208191

0 commit comments

Comments
 (0)