Documentation
¶
Overview ¶
TSA ASN.1 structures for RFC 3161 Time-Stamp Protocol.
⚠️ ASN.1 FREEZE: This package's ASN.1 structures are frozen. Bug fixes only — no new ASN.1 struct types, no new OIDs. See dev-docs/ASN1_DISCIPLINE.md.
Index ¶
- Constants
- Variables
- func BuildErrorResponse(status int, msg string) ([]byte, error)
- func BuildGrantedResponse(tstInfoDER, contentInfoDER []byte) ([]byte, error)
- func BuildTSTInfo(req *TimeStampReq, serial int64, cfg *TSTInfoConfig) ([]byte, int, error)
- func BuildTimeStampReq(hash crypto.Hash, digest []byte, nonce *big.Int) ([]byte, error)
- func ForceRenewSignerCert(rc *RuntimeConfig, renewCfg *RenewalConfig) error
- func NeedsRenewal(cert *x509.Certificate, window time.Duration) bool
- func ParseChainPEM(pemData string) []*x509.Certificate
- func RotateSignerCert(rc *RuntimeConfig, renewCfg *RenewalConfig) error
- func SerialFromBigInt(n *big.Int) int
- func SignRequest(reqDER []byte, cfg *TSAConfig) ([]byte, error)
- func SignerRenewLoop(rc *RuntimeConfig, renewCfg *RenewalConfig, stopCh <-chan struct{})
- type Accuracy
- type AlgorithmIdentifier
- type Handler
- type MessageImprint
- type PKIStatusInfo
- type RenewalConfig
- type RuntimeConfig
- type SignerCertInfo
- type TSAConfig
- type TSTInfo
- type TSTInfoConfig
- type TimeStampReq
- type TimeStampResp
Constants ¶
const ( PKIStatusGranted = 0 PKIStatusGrantedMods = 1 PKIStatusRejection = 2 PKIStatusWaiting = 3 )
Variables ¶
var ( OIDTSTInfo = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 16, 1, 4} OIDDigestSHA256 = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 2, 1} OIDDigestSHA384 = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 2, 2} OIDDigestSHA512 = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 2, 3} OIDEcdsaWithSHA256 = asn1.ObjectIdentifier{1, 2, 840, 10045, 4, 3, 2} OIDEcdsaWithSHA384 = asn1.ObjectIdentifier{1, 2, 840, 10045, 4, 3, 3} OIDEcdsaWithSHA512 = asn1.ObjectIdentifier{1, 2, 840, 10045, 4, 3, 4} )
var OIDTSAPolicyDefault = asn1.ObjectIdentifier{0, 0}
Functions ¶
func BuildGrantedResponse ¶
func BuildTSTInfo ¶
func BuildTSTInfo(req *TimeStampReq, serial int64, cfg *TSTInfoConfig) ([]byte, int, error)
func BuildTimeStampReq ¶
func ForceRenewSignerCert ¶
func ForceRenewSignerCert(rc *RuntimeConfig, renewCfg *RenewalConfig) error
ForceRenewSignerCert triggers an immediate signer certificate renewal regardless of expiry. Used by the management API (POST /tsa/cert/renew).
func NeedsRenewal ¶
func NeedsRenewal(cert *x509.Certificate, window time.Duration) bool
NeedsRenewal returns true if the certificate expires within the window.
func ParseChainPEM ¶
func ParseChainPEM(pemData string) []*x509.Certificate
ParseChainPEM parses a PEM-encoded certificate chain.
func RotateSignerCert ¶
func RotateSignerCert(rc *RuntimeConfig, renewCfg *RenewalConfig) error
RotateSignerCert issues a brand-new signer certificate with a fresh key pair and atomically swaps it in. Used by the management API (POST /tsa/cert/rotate).
func SerialFromBigInt ¶
func SignerRenewLoop ¶
func SignerRenewLoop(rc *RuntimeConfig, renewCfg *RenewalConfig, stopCh <-chan struct{})
SignerRenewLoop periodically checks the TSA signer certificate and renews it via the Varwof Core API before expiry. It atomically swaps the new cert/key into the RuntimeConfig without interrupting service.
The loop stops when stopCh is closed.
Types ¶
type AlgorithmIdentifier ¶
type AlgorithmIdentifier struct {
Algorithm asn1.ObjectIdentifier
Parameters asn1.RawValue `asn1:"optional"`
}
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves TSA requests using a RuntimeConfig that supports hot-swapping.
func NewHandler ¶
NewHandler creates a Handler backed by the given RuntimeConfig.
func NewHandlerWithRuntime ¶
func NewHandlerWithRuntime(rc *RuntimeConfig) *Handler
NewHandlerWithRuntime creates a Handler backed by an existing RuntimeConfig.
func (*Handler) RuntimeConfig ¶
func (h *Handler) RuntimeConfig() *RuntimeConfig
RuntimeConfig returns the underlying RuntimeConfig for hot-swap operations.
type MessageImprint ¶
type MessageImprint struct {
HashAlgorithm AlgorithmIdentifier
HashedMessage []byte
}
type PKIStatusInfo ¶
type RenewalConfig ¶
type RenewalConfig struct {
// CoreURL is the Varwof Core API base URL (e.g., "https://pki.example.com").
CoreURL string
// CertFile is the path to the current signer certificate PEM.
CertFile string
// KeyFile is the path to the current signer private key PEM.
KeyFile string
// CACertFile is the CA certificate for mTLS to Varwof Core.
CACertFile string
// CAName is the CA name to issue from (e.g., "tsa").
CAName string
// ValidityDays is the validity period for new certificates.
ValidityDays int
// RenewalWindow is how far before expiry to trigger renewal.
RenewalWindow time.Duration
// CheckInterval is how often to check for renewal need.
CheckInterval time.Duration
// TLSClientCert is the mTLS client certificate for API calls.
TLSClientCert string
// TLSClientKey is the mTLS client key for API calls.
TLSClientKey string
}
RenewalConfig controls the automatic signer certificate renewal loop.
type RuntimeConfig ¶
type RuntimeConfig struct {
// contains filtered or unexported fields
}
RuntimeConfig holds the TSA signing configuration in a hot-swappable container. The handler reads from the atomic pointer on every request; the renewal loop writes a new config when the signer certificate is renewed.
func NewRuntimeConfig ¶
func NewRuntimeConfig(cfg *TSAConfig) *RuntimeConfig
NewRuntimeConfig creates a RuntimeConfig from an initial TSAConfig.
func (*RuntimeConfig) CertInfo ¶
func (rc *RuntimeConfig) CertInfo() *SignerCertInfo
CertInfo returns metadata about the current signer certificate.
func (*RuntimeConfig) Load ¶
func (rc *RuntimeConfig) Load() *TSAConfig
Load returns the current TSAConfig. Never returns nil after construction.
func (*RuntimeConfig) Store ¶
func (rc *RuntimeConfig) Store(cfg *TSAConfig)
Store atomically replaces the current TSAConfig.
type SignerCertInfo ¶
type SignerCertInfo struct {
SerialNumber string `json:"serial_number"`
Subject string `json:"subject"`
Issuer string `json:"issuer"`
NotBefore string `json:"not_before"`
NotAfter string `json:"not_after"`
HasChain bool `json:"has_chain"`
}
SignerCertInfo returns metadata about the current signer certificate.
type TSAConfig ¶
type TSAConfig struct {
SignerCert *x509.Certificate
SignerKey crypto.Signer
Chain []*x509.Certificate
TSTInfo *TSTInfoConfig
}
type TSTInfo ¶
type TSTInfo struct {
Version int
Policy asn1.ObjectIdentifier
MessageImprint MessageImprint
SerialNumber int64
GenTime asn1.RawValue
Accuracy Accuracy `asn1:"optional"`
Ordering bool `asn1:"optional,default:false"`
Nonce *big.Int `asn1:"optional"`
TSA asn1.RawValue `asn1:"optional,tag:0"`
TSTInfoExt []asn1.RawValue `asn1:"optional,tag:1"`
}
type TSTInfoConfig ¶
type TimeStampReq ¶
type TimeStampReq struct {
Version int
MessageImprint MessageImprint
ReqPolicy asn1.ObjectIdentifier `asn1:"optional"`
Nonce *big.Int `asn1:"optional"`
CertReq bool `asn1:"optional,default:false"`
Extensions []asn1.RawValue `asn1:"optional,tag:0"`
}
func ParseTimeStampReq ¶
func ParseTimeStampReq(reqDER []byte) (*TimeStampReq, error)
type TimeStampResp ¶
type TimeStampResp struct {
Status PKIStatusInfo
TimeStampToken asn1.RawValue `asn1:"optional"`
}