Skip to content

Commit

Permalink
Merge pull request #7204 from terraform-providers/b/key-vault-cert-th…
Browse files Browse the repository at this point in the history
…umbprint

r/key_vault_certificate: always setting the `certificate_data` and `thumbprint` fields
  • Loading branch information
tombuildsstuff authored Jun 4, 2020
2 parents 186865b + 4d89b18 commit d4d7099
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,17 +510,22 @@ func resourceArmKeyVaultCertificateRead(d *schema.ResourceData, meta interface{}
d.Set("version", id.Version)
d.Set("secret_id", cert.Sid)

certificateData := ""
if contents := cert.Cer; contents != nil {
d.Set("certificate_data", strings.ToUpper(hex.EncodeToString(*contents)))
certificateData = strings.ToUpper(hex.EncodeToString(*contents))
}
d.Set("certificate_data", certificateData)

thumbprint := ""
if v := cert.X509Thumbprint; v != nil {
x509Thumbprint, err := base64.RawURLEncoding.DecodeString(*v)
if err != nil {
return err
}
d.Set("thumbprint", strings.ToUpper(hex.EncodeToString(x509Thumbprint)))

thumbprint = strings.ToUpper(hex.EncodeToString(x509Thumbprint))
}
d.Set("thumbprint", thumbprint)

return tags.FlattenAndSet(d, cert.Tags)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func TestAccAzureRMKeyVaultCertificate_basicGenerate(t *testing.T) {
testCheckAzureRMKeyVaultCertificateExists(data.ResourceName),
resource.TestCheckResourceAttrSet(data.ResourceName, "secret_id"),
resource.TestCheckResourceAttrSet(data.ResourceName, "certificate_data"),
resource.TestCheckResourceAttrSet(data.ResourceName, "thumbprint"),
),
},
data.ImportStep(),
Expand Down

0 comments on commit d4d7099

Please sign in to comment.