diff --git a/go.mod b/go.mod index bf61b6b7..410c54ca 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 github.com/pkg/errors v0.9.1 github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a - golang.org/x/crypto v0.23.0 software.sslmate.com/src/go-pkcs12 v0.4.0 ) @@ -207,6 +206,7 @@ require ( go.tmz.dev/musttag v0.7.2 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect + golang.org/x/crypto v0.23.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/exp/typeparams v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.17.0 // indirect diff --git a/test_files/cert-legacy.p12 b/test_files/cert-legacy.p12 new file mode 100644 index 00000000..4d1de386 Binary files /dev/null and b/test_files/cert-legacy.p12 differ diff --git a/test_files/cert.p12 b/test_files/cert.p12 new file mode 100644 index 00000000..ec43c413 Binary files /dev/null and b/test_files/cert.p12 differ diff --git a/venafi/provider.go b/venafi/provider.go index 2bce6a08..def4c2c8 100644 --- a/venafi/provider.go +++ b/venafi/provider.go @@ -10,7 +10,7 @@ import ( "os" "strings" - "golang.org/x/crypto/pkcs12" + "software.sslmate.com/src/go-pkcs12" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" diff --git a/venafi/provider_test.go b/venafi/provider_test.go index 093dee52..c6dd9b2e 100644 --- a/venafi/provider_test.go +++ b/venafi/provider_test.go @@ -1,6 +1,7 @@ package venafi import ( + "context" "fmt" "regexp" "testing" @@ -8,6 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +const certPassword = "test123" + var testAccProviderFactories map[string]func() (*schema.Provider, error) func init() { @@ -50,3 +53,15 @@ func TestNormalizedZones(t *testing.T) { } } } + +func TestSetTLSConfig(t *testing.T) { + certs := []string{"cert.p12", "cert-legacy.p12"} + for _, v := range certs { + loc := GetAbsoluteFIlePath(fmt.Sprintf("/test_files/%s", v)) + ctx := context.Background() + err := setTLSConfig(ctx, loc, certPassword) + if err != nil { + t.Fatalf("Failed set TLS Config: %s", err) + } + } +}