smallstep / crypto

Crypto is a collection of packages used by Smallstep products
Apache License 2.0
75 stars 24 forks source link

Add support validities in templates #534

Closed maraino closed 3 months ago

maraino commented 4 months ago

Description

This commit allows setting the validity bounds on X.509 and SSH certificates using templates.

It also adds the template method toTime, which makes it easier to format a timestamp to RFC3339. This format is compatible with Go's time.Time when json.Unmarshal is used. There are similar methods to do this in the sprig library, but they require you to specify the format string. For example, these methods will return a valid string that can be unmarshaled to time.Time:

{{ date "2006-01-02T15:04:05Z07:00" .Token.nbf | toJson }}
{{ dateInZone "2006-01-02T15:04:05Z07:00" .Token.nbf "UTC" | toJson }}
{{ toTime .Token.nbf | toJson }}
hslatman commented 3 months ago

That lint issue is my bad with the GH editor