checker

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK = Status(iota)
	WARNING
	CRITICAL
	UNKNOWN
	INFO  // for internal statuses
	ERROR // for internal statuses
)

Status Code

View Source
const (
	// Default output format
	DefaultFormat = OutputFormat(iota)

	// JSON output format
	JSONFormat
)

Variables

This section is empty.

Functions

func GetCurrentTime added in v0.9.0

func GetCurrentTime() time.Time

GetCurrentTime gets a current time.

func GetDNType added in v0.9.0

func GetDNType() x509util.DNType

GetDNType gets a Distinguished Name type.

func GetOutput

func GetOutput() io.Writer

GetOutput gets the output.

func GetVerbose added in v0.9.0

func GetVerbose() int

GetVerbose gets a verbose mode.

func Print

func Print(a ...interface{}) (n int, err error)

Print formats using the default formats for its operands and writes to the specified output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.

func Printf

func Printf(format string, a ...interface{}) (n int, err error)

Printf formats according to a format specifier and writes to the specified output. It returns the number of bytes written and any write error encountered.

func Println

func Println(a ...interface{}) (n int, err error)

Println formats using the default formats for its operands and writes to the specified output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.

func SetCurrentTime added in v0.9.0

func SetCurrentTime(t time.Time)

SetCurrentTime sets a current time.

func SetDNType added in v0.9.0

func SetDNType(t x509util.DNType)

SetDNType sets a Distinguished Name type.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the output.

func SetVerbose added in v0.9.0

func SetVerbose(v int)

SetVerbose sets a verbose mode.

Types

type CertificateChainChecker added in v0.9.0

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

CertificateChainChecker represents wheather certificate chains are valid.

func NewCertificateChainChecker added in v0.9.0

func NewCertificateChainChecker(certs []*x509.Certificate, rootCertPool *x509.CertPool) *CertificateChainChecker

func (*CertificateChainChecker) Details added in v0.9.0

func (c *CertificateChainChecker) Details() interface{}

func (*CertificateChainChecker) Message added in v0.9.0

func (c *CertificateChainChecker) Message() string

func (*CertificateChainChecker) Name added in v0.9.0

func (c *CertificateChainChecker) Name() string

func (*CertificateChainChecker) PrintDetails added in v0.9.0

func (c *CertificateChainChecker) PrintDetails()

func (*CertificateChainChecker) PrintName added in v0.9.0

func (c *CertificateChainChecker) PrintName()

func (*CertificateChainChecker) PrintStatus added in v0.9.0

func (c *CertificateChainChecker) PrintStatus()

func (*CertificateChainChecker) Status added in v0.9.0

func (c *CertificateChainChecker) Status() Status

type CertificateChainDetails added in v0.9.0

type CertificateChainDetails [][]CertificateInfo

func NewCertificateChainDetails added in v0.9.0

func NewCertificateChainDetails(c [][]CertificateInfo) CertificateChainDetails

type CertificateChecker added in v0.9.0

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

CertificateChecker represents a certificate information.

func NewCertificateChecker added in v0.9.0

func NewCertificateChecker(cert *x509.Certificate) *CertificateChecker

func (*CertificateChecker) Details added in v0.9.0

func (c *CertificateChecker) Details() interface{}

func (*CertificateChecker) Message added in v0.9.0

func (c *CertificateChecker) Message() string

func (*CertificateChecker) Name added in v0.9.0

func (c *CertificateChecker) Name() string

func (*CertificateChecker) PrintDetails added in v0.9.0

func (c *CertificateChecker) PrintDetails()

func (*CertificateChecker) PrintName added in v0.9.0

func (c *CertificateChecker) PrintName()

func (*CertificateChecker) PrintStatus added in v0.9.0

func (c *CertificateChecker) PrintStatus()

func (*CertificateChecker) Status added in v0.9.0

func (c *CertificateChecker) Status() Status

type CertificateDetails added in v0.9.0

type CertificateDetails struct {
	Issuer               string           `json:"issuer"`
	Subject              string           `json:"subject"`
	SubjectAltName       []subjectAltName `json:"subjectAltName,omitempty"`
	Validity             validity         `json:"validity"`
	SubjectPublicKeyInfo *publicKeyInfo   `json:"subjectPublicKeyInfo,omitempty"`
}

func NewCertificateDetails added in v0.9.0

func NewCertificateDetails(cert *x509.Certificate) *CertificateDetails

type CertificateFileInfo

type CertificateFileInfo struct {
	Name                string            `json:"name"`
	File                string            `json:"file"`
	Status              Status            `json:"-"`
	StatusString        string            `json:"status"`
	Error               string            `json:"error,omitempty"`
	CertificateInfoList []CertificateInfo `json:"certificate"`
	// contains filtered or unexported fields
}

CertificateFileInfo describes an information in a certificate file.

func NewCertificateFileInfo added in v0.9.0

func NewCertificateFileInfo(name string, certFile string, parent *x509.Certificate, isRoot bool) (CertificateFileInfo, *x509.Certificate)

type CertificateFilesChecker added in v0.9.0

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

CertificateFilesChecker represents certificate files are.

func NewCertificateFilesChecker added in v0.9.0

func NewCertificateFilesChecker(certFile string, chainFile string, caFile string, rootFile string) *CertificateFilesChecker

func (*CertificateFilesChecker) Details added in v0.9.0

func (c *CertificateFilesChecker) Details() interface{}

func (*CertificateFilesChecker) Message added in v0.9.0

func (c *CertificateFilesChecker) Message() string

func (*CertificateFilesChecker) Name added in v0.9.0

func (c *CertificateFilesChecker) Name() string

func (*CertificateFilesChecker) PrintDetails added in v0.9.0

func (c *CertificateFilesChecker) PrintDetails()

func (*CertificateFilesChecker) PrintName added in v0.9.0

func (c *CertificateFilesChecker) PrintName()

func (*CertificateFilesChecker) PrintStatus added in v0.9.0

func (c *CertificateFilesChecker) PrintStatus()

func (*CertificateFilesChecker) Status added in v0.9.0

func (c *CertificateFilesChecker) Status() Status

type CertificateFilesDetails added in v0.9.0

type CertificateFilesDetails []CertificateFileInfo

func NewCertificateFilesDetails added in v0.9.0

func NewCertificateFilesDetails(list []CertificateFileInfo) CertificateFilesDetails

type CertificateInfo

type CertificateInfo struct {
	CommonName   string `json:"commonName"`
	Status       Status `json:"-"`
	StatusString string `json:"status"`
	Subject      string `json:"subject"`
	Issuer       string `json:"issuer"`
	Expiration   string `json:"expiration"`
	Message      string `json:"message,omitempty"`
	Error        string `json:"error,omitempty"`
}

func NewCertificateInfo added in v0.9.0

func NewCertificateInfo(cert *x509.Certificate, parent *x509.Certificate, forceParentToCheck bool) CertificateInfo

type CertificateListChecker added in v0.9.0

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

CertificateListChecker represents wheather peer certificates are valid.

func NewCertificateListChecker added in v0.9.0

func NewCertificateListChecker(certs []*x509.Certificate) *CertificateListChecker

func (*CertificateListChecker) Details added in v0.9.0

func (c *CertificateListChecker) Details() interface{}

func (*CertificateListChecker) Message added in v0.9.0

func (c *CertificateListChecker) Message() string

func (*CertificateListChecker) Name added in v0.9.0

func (c *CertificateListChecker) Name() string

func (*CertificateListChecker) PrintDetails added in v0.9.0

func (c *CertificateListChecker) PrintDetails()

func (*CertificateListChecker) PrintName added in v0.9.0

func (c *CertificateListChecker) PrintName()

func (*CertificateListChecker) PrintStatus added in v0.9.0

func (c *CertificateListChecker) PrintStatus()

func (*CertificateListChecker) Status added in v0.9.0

func (c *CertificateListChecker) Status() Status

type CertificateListDetails added in v0.9.0

type CertificateListDetails []CertificateInfo

func NewCertificateListDetails added in v0.9.0

func NewCertificateListDetails(list []CertificateInfo) CertificateListDetails

type Checker added in v0.9.0

type Checker interface {
	Name() string
	Status() Status
	Message() string
	Details() interface{}
	PrintName()
	PrintStatus()
	PrintDetails()
}

type HostnameChecker added in v0.9.0

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

HostnameChecker represents whether a hostname is valid for a certificate.

func NewHostnameChecker added in v0.9.0

func NewHostnameChecker(hostname string, cert *x509.Certificate) *HostnameChecker

func (*HostnameChecker) Details added in v0.9.0

func (c *HostnameChecker) Details() interface{}

func (*HostnameChecker) Message added in v0.9.0

func (c *HostnameChecker) Message() string

func (*HostnameChecker) Name added in v0.9.0

func (c *HostnameChecker) Name() string

func (*HostnameChecker) PrintDetails added in v0.9.0

func (c *HostnameChecker) PrintDetails()

func (*HostnameChecker) PrintName added in v0.9.0

func (c *HostnameChecker) PrintName()

func (*HostnameChecker) PrintStatus added in v0.9.0

func (c *HostnameChecker) PrintStatus()

func (*HostnameChecker) Status added in v0.9.0

func (c *HostnameChecker) Status() Status

type HostnameDetails added in v0.9.0

type HostnameDetails struct {
	CommonName     string           `json:"commonName"`
	SubjectAltName []subjectAltName `json:"subjectAltName,omitempty"`
}

func NewHostnameDetails added in v0.9.0

func NewHostnameDetails(cert *x509.Certificate) *HostnameDetails

type JSONableResult added in v0.9.0

type JSONableResult struct {
	Metadata jsonableMetadata `json:"metadata"`
	Result   jsonableResult   `json:"result,omitempty"`
}

type KeyPairChecker added in v0.9.0

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

KeyPairChecker represents wheather a private key is paired with a certificate.

func NewKeyPairChecker added in v0.9.0

func NewKeyPairChecker(pubKeyInfoInPrivKey, pubKeyInfo x509util.PublicKeyInfo) *KeyPairChecker

func (*KeyPairChecker) Details added in v0.9.0

func (c *KeyPairChecker) Details() interface{}

func (*KeyPairChecker) Message added in v0.9.0

func (c *KeyPairChecker) Message() string

func (*KeyPairChecker) Name added in v0.9.0

func (c *KeyPairChecker) Name() string

func (*KeyPairChecker) PrintDetails added in v0.9.0

func (c *KeyPairChecker) PrintDetails()

func (*KeyPairChecker) PrintName added in v0.9.0

func (c *KeyPairChecker) PrintName()

func (*KeyPairChecker) PrintStatus added in v0.9.0

func (c *KeyPairChecker) PrintStatus()

func (*KeyPairChecker) Status added in v0.9.0

func (c *KeyPairChecker) Status() Status

type KeyPairDetails added in v0.9.0

type KeyPairDetails struct {
	PrivateKey  *publicKeyInfo `json:"privateKey"`
	Certificate *publicKeyInfo `json:"certificate"`
}

func NewKeyPairDetails added in v0.9.0

func NewKeyPairDetails(pubKeyInfoInPrivKey, pubKeyInfo x509util.PublicKeyInfo) *KeyPairDetails

type OCSPResponderChecker added in v0.9.0

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

OCSPResponderChecker represents wheather the response from OCSP Responder is valie.

func NewOCSPResponderChecker added in v0.9.0

func NewOCSPResponderChecker(targetCert *x509.Certificate, issuer *x509.Certificate, intermediateCerts []*x509.Certificate, rootCertPool *x509.CertPool) *OCSPResponderChecker

func (*OCSPResponderChecker) Details added in v0.9.0

func (c *OCSPResponderChecker) Details() interface{}

func (*OCSPResponderChecker) Message added in v0.9.0

func (c *OCSPResponderChecker) Message() string

func (*OCSPResponderChecker) Name added in v0.9.0

func (c *OCSPResponderChecker) Name() string

func (*OCSPResponderChecker) PrintDetails added in v0.9.0

func (c *OCSPResponderChecker) PrintDetails()

func (*OCSPResponderChecker) PrintName added in v0.9.0

func (c *OCSPResponderChecker) PrintName()

func (*OCSPResponderChecker) PrintStatus added in v0.9.0

func (c *OCSPResponderChecker) PrintStatus()

func (*OCSPResponderChecker) Status added in v0.9.0

func (c *OCSPResponderChecker) Status() Status

type OCSPResponseData added in v0.9.0

type OCSPResponseData struct {
	OCSPResponseStatus string `json:"oCSPResponseStatus,omitempty"`
	CertStatus         string `json:"certStatus,omitempty"`
	ProducedAt         string `json:"producedAt,omitempty"`
	RevocationTime     string `json:"revocationTime,omitempty"`
	RevocationReason   string `json:"revocationReason,omitempty"`
	ThisUpdate         string `json:"thisUpdate,omitempty"`
	NextUpdate         string `json:"nextUpdate,omitempty"`
}

type OCSPResponseDetails added in v0.9.0

type OCSPResponseDetails struct {
	OCSPResponder    string              `json:"oCSPResponder,omitempty"`
	OCSPResponseData *OCSPResponseData   `json:"oCSPResponseData,omitempty"`
	Certificate      *CertificateDetails `json:"certificate,omitempty"`
}

OCSPResponseDetails is an OCSP response.

func NewOCSPResponseData added in v0.9.0

func NewOCSPResponseData(responseInfo *OCSPResponseInfo) *OCSPResponseDetails

type OCSPResponseInfo

type OCSPResponseInfo struct {
	Status         Status
	Message        string
	Server         string
	Response       *ocsp.Response
	ResponseStatus ocsp.ResponseStatus
}

OCSPResponseInfo describes an information of OCSP response.

func NewOCSPResponseInfo added in v0.9.0

func NewOCSPResponseInfo(ocspResponse []byte, targetCert, issuer *x509.Certificate, intermediateCerts []*x509.Certificate, rootCertPool *x509.CertPool) *OCSPResponseInfo

type OCSPStaplingChecker added in v0.9.0

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

OCSPStaplingChecker represents wheather the response from OCSP Stapling is valid.

func NewOCSPStaplingChecker added in v0.9.0

func NewOCSPStaplingChecker(ocspResponse []byte, issuer *x509.Certificate, intermediateCerts []*x509.Certificate, rootCertPool *x509.CertPool, allowNonReponse bool) *OCSPStaplingChecker

NewOCSPStaplingChecker returns a new OCSPStaplingChecker.

func (*OCSPStaplingChecker) Details added in v0.9.0

func (c *OCSPStaplingChecker) Details() interface{}

func (*OCSPStaplingChecker) Message added in v0.9.0

func (c *OCSPStaplingChecker) Message() string

func (*OCSPStaplingChecker) Name added in v0.9.0

func (c *OCSPStaplingChecker) Name() string

func (*OCSPStaplingChecker) PrintDetails added in v0.9.0

func (c *OCSPStaplingChecker) PrintDetails()

func (*OCSPStaplingChecker) PrintName added in v0.9.0

func (c *OCSPStaplingChecker) PrintName()

func (*OCSPStaplingChecker) PrintStatus added in v0.9.0

func (c *OCSPStaplingChecker) PrintStatus()

func (*OCSPStaplingChecker) Status added in v0.9.0

func (c *OCSPStaplingChecker) Status() Status

type OutputFormat added in v0.9.0

type OutputFormat int

OutputFormat is a output format.

type Result added in v0.9.0

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

func NewResult added in v0.9.0

func NewResult(summary *Summary, list []Checker) *Result

func (*Result) Print added in v0.9.0

func (r *Result) Print()

func (*Result) PrintJSON added in v0.9.0

func (r *Result) PrintJSON()

type Status

type Status int

Status is a status code for monitoring.

func (Status) Code

func (s Status) Code() int

Code returns a status code.

func (Status) ColorString

func (s Status) ColorString() string

ColorString returns a status string with color.

func (Status) String

func (s Status) String() string

String returns a status string.

type Summary added in v0.9.0

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

func NewErrorSummary added in v0.9.0

func NewErrorSummary(err error) *Summary

func NewSummary added in v0.9.0

func NewSummary(list []Checker) *Summary

func (*Summary) Details added in v0.9.0

func (s *Summary) Details() interface{}

func (*Summary) Message added in v0.9.0

func (s *Summary) Message() string

func (*Summary) Name added in v0.9.0

func (s *Summary) Name() string

func (*Summary) PrintDetails added in v0.9.0

func (s *Summary) PrintDetails()

func (*Summary) PrintName added in v0.9.0

func (s *Summary) PrintName()

func (*Summary) PrintStatus added in v0.9.0

func (s *Summary) PrintStatus()

func (*Summary) Status added in v0.9.0

func (s *Summary) Status() Status

type ValidityChecker added in v0.9.0

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

ValidityChecker represents wheather the validity of a certificate is valid.

func NewValidityChecker added in v0.9.0

func NewValidityChecker(cert *x509.Certificate, warning int, critical int) *ValidityChecker

NewValidityChecker returns a new ValidityChecker.

func (*ValidityChecker) Details added in v0.9.0

func (c *ValidityChecker) Details() interface{}

func (*ValidityChecker) Message added in v0.9.0

func (c *ValidityChecker) Message() string

func (*ValidityChecker) Name added in v0.9.0

func (c *ValidityChecker) Name() string

func (*ValidityChecker) PrintDetails added in v0.9.0

func (c *ValidityChecker) PrintDetails()

func (*ValidityChecker) PrintName added in v0.9.0

func (c *ValidityChecker) PrintName()

func (*ValidityChecker) PrintStatus added in v0.9.0

func (c *ValidityChecker) PrintStatus()

func (*ValidityChecker) Status added in v0.9.0

func (c *ValidityChecker) Status() Status

type ValidityDetails added in v0.9.0

type ValidityDetails struct {
	NotBefore string `json:"notBefore"`
	NotAfter  string `json:"notAfter"`
}

ValidityDetails is the validity of a certificate.

func NewValidityDetails added in v0.9.0

func NewValidityDetails(cert *x509.Certificate) *ValidityDetails

NewValidityDetails returns a new ValidityDetails.

Jump to

Keyboard shortcuts

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