Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_key_vault_certificate return thumbprint as hex #1904

Merged
merged 3 commits into from
Sep 11, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions azurerm/resource_arm_key_vault_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package azurerm

import (
"context"
"encoding/base64"
"encoding/hex"
"fmt"
"log"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/keyvault/2016-10-01/keyvault"
Expand Down Expand Up @@ -236,6 +239,11 @@ func resourceArmKeyVaultCertificate() *schema.Resource {
Computed: true,
},

"thumbprint": {
Type: schema.TypeString,
Computed: true,
},
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved

"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -349,6 +357,15 @@ func resourceArmKeyVaultCertificateRead(d *schema.ResourceData, meta interface{}
if contents := cert.Cer; contents != nil {
d.Set("certificate_data", string(*contents))
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming the thumbprint is case insensitive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the cluster will accept lowercase, I was trying to replicate as close as possible what the Azure CLI returns

}

flattenAndSetTags(d, cert.Tags)

return nil
Expand Down