Search code examples
hashicorp-vault

HashiCorp Vault: Generate Certificate and Key: What is the format for time-to-live (ttl)?


HashiCorp Vault REST API has an endpoint to generate (signed) cert and key: /pki/issue/:name

Official docs: https://developer.hashicorp.com/vault/api-docs/secret/pki#generate-certificate-and-key

In the body of the request, there is a JSON object key "ttl" for time-to-live. What are the supported value formats for this key?

I cannot find supported formats in official docs. By luck, I found other examples that allow suffices "h" for hours, e.g., "360h", and "d" for days, e.g., "7d".


Solution

  • It expects a time duration string parsable by Go time.ParseDuration.

    https://github.com/hashicorp/vault/issues/1195

    https://pkg.go.dev/time#ParseDuration