package ca

import (
	"time"
)

// CAConfig is the CA engine configuration stored in the barrier.
type CAConfig struct {
	Organization string `json:"organization"`
	Country      string `json:"country,omitempty"`
	KeyAlgorithm string `json:"key_algorithm"`
	RootExpiry   string `json:"root_expiry"`
	ExternalURL  string `json:"external_url,omitempty"`
	KeySize      int    `json:"key_size"`
}

// IssuerConfig is per-issuer configuration stored in the barrier.
type IssuerConfig struct {
	CreatedAt    time.Time `json:"created_at"`
	Name         string    `json:"name"`
	KeyAlgorithm string    `json:"key_algorithm"`
	Expiry       string    `json:"expiry"`
	MaxTTL       string    `json:"max_ttl"`
	CreatedBy    string    `json:"created_by"`
	KeySize      int       `json:"key_size"`
}

// CertRecord is metadata for an issued certificate, stored in the barrier.
// The private key is NOT stored.
type CertRecord struct {
	IssuedAt  time.Time `json:"issued_at"`
	ExpiresAt time.Time `json:"expires_at"`
	RevokedAt time.Time `json:"revoked_at,omitempty"`
	Serial    string    `json:"serial"`
	Issuer    string    `json:"issuer"`
	CN        string    `json:"cn"`
	Profile   string    `json:"profile"`
	CertPEM   string    `json:"cert_pem"`
	IssuedBy  string    `json:"issued_by"`
	RevokedBy string    `json:"revoked_by,omitempty"`
	SANs      []string  `json:"sans,omitempty"`
	Revoked   bool      `json:"revoked,omitempty"`
}
