INNER CODE UNIT · Go
pubKeyHash
hashicorp/terraform-provider-tls · internal/provider/common_cert.go:110
pubKeyHash := sha1.Sum(pubKeyBytes)
return pubKeyHash[:], nil
}
func createCertificate(ctx context.Context, template, parent *x509.Certificate, pubKey crypto.PublicKey, prvKey crypto.PrivateKey, plan *tfsdk.Plan) (*commonCertificate, diag.Diagnostics) {
var err error
var diags diag.Diagnostics
// Set not-before and not-after limits on the certificate template
validityPeriodHoursPath := path.Root("validity_period_hours")
var validityPeriodHours int64
diags.Append(plan.GetAttribute(ctx, validityPeriodHoursPath, &validityPeriodHours)...)
if diags.HasError() {
return nil, diags
}
template.NotBefore = overridableTimeFunc()
template.NotAfter = template.NotBefore.Add(time.Duration(validityPeriodHours) * time.Hour)