certificates

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Certificate

type Certificate struct {
	ID          uint      `gorm:"primaryKey"`
	Domain      string    `gorm:"column:domain;uniqueIndex;size:255"`
	Port        int       `gorm:"column:port;default:443"`
	Issuer      string    `gorm:"column:issuer;size:500"`
	Subject     string    `gorm:"column:subject;size:500"`
	Algorithm   string    `gorm:"column:algorithm;size:100"`
	KeyUsage    string    `gorm:"column:key_usage;size:200"`
	ValidFrom   time.Time `gorm:"column:valid_from"`
	ValidTo     time.Time `gorm:"column:valid_to"`
	DaysLeft    int       `gorm:"column:days_left"`
	Status      string    `gorm:"column:status;size:50"` // valid, expired, expiring, error
	LastChecked time.Time `gorm:"column:last_checked"`
	ErrorMsg    string    `gorm:"column:error_msg;type:text"`
	AlertDays   int       `gorm:"column:alert_days;default:30"` // Alert when days left <= this value
	Enabled     bool      `gorm:"column:enabled;default:true"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Certificate represents a monitored SSL certificate

func (Certificate) TableName

func (Certificate) TableName() string

type CertificateAlert

type CertificateAlert struct {
	ID            uint       `gorm:"primaryKey"`
	CertificateID uint       `gorm:"column:certificate_id;index"`
	AlertType     string     `gorm:"column:alert_type;size:50"` // email, sms, webhook, chat
	Target        string     `gorm:"column:target;size:500"`    // email address, phone, webhook URL, chat ID
	Enabled       bool       `gorm:"column:enabled;default:true"`
	LastSent      *time.Time `gorm:"column:last_sent"`
	CreatedAt     time.Time
	UpdatedAt     time.Time

	Certificate Certificate `gorm:"foreignKey:CertificateID"`
}

CertificateAlert represents alert configuration

func (CertificateAlert) TableName

func (CertificateAlert) TableName() string

type CertificateStats

type CertificateStats struct {
	Total       int64     `json:"total"`
	Valid       int64     `json:"valid"`
	Expiring    int64     `json:"expiring"`
	Expired     int64     `json:"expired"`
	Errors      int64     `json:"errors"`
	LastChecked time.Time `json:"last_checked"`
}

CertificateStats contains certificate statistics

type DomainInfo

type DomainInfo struct {
	Domain           string     `json:"domain"`
	Registrar        string     `json:"registrar"`
	RegistrationDate *time.Time `json:"registration_date,omitempty"`
	ExpirationDate   *time.Time `json:"expiration_date,omitempty"`
	NameServers      []string   `json:"name_servers"`
	DaysToExpiry     int        `json:"days_to_expiry"`
	Status           string     `json:"status"`
}

DomainInfo contains domain registration information

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store handles certificate monitoring

func NewStore

func NewStore(db *gorm.DB) *Store

func (*Store) AddAlert

func (s *Store) AddAlert(certID uint, alertType, target string) error

AddAlert adds an alert for a certificate

func (*Store) AddDomain

func (s *Store) AddDomain(domain string, port int, alertDays int) error

AddDomain adds a domain to monitor

func (*Store) AutoMigrate

func (s *Store) AutoMigrate() error

AutoMigrate creates certificate tables

func (*Store) CheckAllCertificates

func (s *Store) CheckAllCertificates() error

CheckAllCertificates checks all enabled certificates

func (*Store) CheckCertificate

func (s *Store) CheckCertificate(certID uint) error

CheckCertificate checks a single certificate

func (*Store) Delete

func (s *Store) Delete(id uint) error

Delete removes a certificate from monitoring

func (*Store) GetAlertsForCertificate

func (s *Store) GetAlertsForCertificate(certID uint) ([]CertificateAlert, error)

GetAlertsForCertificate returns alerts for a specific certificate

func (*Store) GetByID

func (s *Store) GetByID(id uint) (*Certificate, error)

GetByID returns a certificate by ID

func (*Store) GetCertificateStats

func (s *Store) GetCertificateStats() (*CertificateStats, error)

GetCertificateStats returns certificate statistics

func (*Store) GetDomainInfo

func (s *Store) GetDomainInfo(domain string) (*DomainInfo, error)

GetDomainInfo attempts to get domain registration info (basic implementation)

func (*Store) GetExpiringCertificates

func (s *Store) GetExpiringCertificates() ([]Certificate, error)

GetExpiringCertificates returns certificates that are expiring or expired

func (*Store) ListCertificates

func (s *Store) ListCertificates(page, size int, status string) ([]Certificate, int64, error)

ListCertificates returns all certificates with pagination

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL