Files
pki/Documentation/api/cmd_xpki-tool_cli.md

12 KiB

cli

import "github.com/effective-security/xpki/cmd/xpki-tool/cli"

Package cli implements the xpki-tool command tree: csr-info, cert info/validate, crl info/fetch and ocsp info/fetch. Network operations honor the global --timeout flag.

Index

func CRLValidation

func CRLValidation(ctx context.Context, client *http.Client, crt *x509.Certificate, issuer *x509.Certificate, crlURL string) (int, error)

CRLValidation calls CRL Endpoint and check certificate in CRL

func OCSPValidation

func OCSPValidation(ctx context.Context, client *http.Client, crt *x509.Certificate, issuer *x509.Certificate, rawURL string) (int, []byte, error)

OCSPValidation calls OCSP server and validate certificate

type CRLCmd

CRLCmd provides commands for CRL

type CRLCmd struct {
    Info  CRLInfoCmd  `cmd:"" help:"print CRL info"`
    Fetch CRLFetchCmd `cmd:"" help:"fetch CRL"`
}

type CRLFetchCmd

CRLFetchCmd specifies flags for CRLFetch action

type CRLFetchCmd struct {
    Cert   string `kong:"arg" required:"" help:"certificate file name"`
    Output string `help:"output folder name; required unless --print is set"`
    All    bool   `help:"fetch entire chain"`
    Proxy  string `help:"optional, proxy address or DC name"`
    Print  bool   `help:"print the fetched CRL"`
}

func (*CRLFetchCmd) Run

func (a *CRLFetchCmd) Run(ctx *Cli) error

Run the command

type CRLInfoCmd

CRLInfoCmd prints crl info

type CRLInfoCmd struct {
    In string `kong:"arg" required:"" help:"DER-encoded CRL"`
}

func (*CRLInfoCmd) Run

func (a *CRLInfoCmd) Run(ctx *Cli) error

Run the command

type CertInfoCmd

CertInfoCmd specifies flags for CertInfo action

type CertInfoCmd struct {
    In         string `kong:"arg" required:"" help:"certificate file name"`
    Out        string `help:"optional, output file to save parsed certificates"`
    NotAfter   string `help:"optional, filter certificates by NotAfter time"`
    NoExpired  *bool  `help:"optional, filter non-expired certificates"`
    Extensions bool   `help:"optional, print extensions values"`
}

func (*CertInfoCmd) Run

func (a *CertInfoCmd) Run(ctx *Cli) error

Run the command

type CertValidateCmd

CertValidateCmd specifies flags for Validate action

type CertValidateCmd struct {
    Cert       string `kong:"arg" required:"" help:"certificate file name"`
    CA         string `help:"optional, CA bundle file"`
    Root       string `help:"optional, Trusted Roots file"`
    Out        string `help:"optional, output file to save certificate chain"`
    Revocation bool   `help:"optional, validate certificate revocation status"`
    Proxy      string `help:"optional, proxy address or DC name"`
    WithAIA    bool   `help:"optional, enable AIA to fetch intermediates"`
}

func (*CertValidateCmd) Run

func (a *CertValidateCmd) Run(ctx *Cli) error

Run the command

type CertsCmd

CertsCmd provides certificates commands

type CertsCmd struct {
    Info     CertInfoCmd     `cmd:"" help:"print certificate info"`
    Validate CertValidateCmd `cmd:"" help:"validates certificate"`
}

type Cli

Cli provides CLI context to run commands

type Cli struct {
    Version ctl.VersionFlag `name:"version" help:"Print version information and quit" hidden:""`

    Timeout int `help:"HTTP timeout in seconds" default:"3"`
    // contains filtered or unexported fields
}

func (*Cli) AfterApply

func (c *Cli) AfterApply(_ *kong.Kong, _ kong.Vars) error

AfterApply hook loads config

func (*Cli) Context

func (c *Cli) Context() context.Context

Context for requests

func (*Cli) ErrWriter

func (c *Cli) ErrWriter() io.Writer

ErrWriter returns a writer for control output

func (*Cli) ReadFile

func (c *Cli) ReadFile(filename string) ([]byte, error)

ReadFile reads from stdin if the file is "-"

func (*Cli) Reader

func (c *Cli) Reader() io.Reader

Reader is the source to read from, typically set to os.Stdin

func (*Cli) WithErrWriter

func (c *Cli) WithErrWriter(out io.Writer) *Cli

WithErrWriter allows to specify a custom error writer

func (*Cli) WithReader

func (c *Cli) WithReader(reader io.Reader) *Cli

WithReader allows to specify a custom reader

func (*Cli) WithWriter

func (c *Cli) WithWriter(out io.Writer) *Cli

WithWriter allows to specify a custom writer

func (*Cli) WriteJSON

func (c *Cli) WriteJSON(value any)

WriteJSON prints response to out

func (*Cli) Writer

func (c *Cli) Writer() io.Writer

Writer returns a writer for control output

type CsrInfoCmd

CsrInfoCmd specifies flags for Info command

type CsrInfoCmd struct {
    Csr string `kong:"arg" required:"" help:"CSR file name"`
}

func (*CsrInfoCmd) Run

func (a *CsrInfoCmd) Run(ctx *Cli) error

Run the command

type OCSPCmd

OCSPCmd is the parent for crl command

type OCSPCmd struct {
    Info  OCSPInfoCmd  `cmd:"" help:"prints OCSP info"`
    Fetch OCSPFetchCmd `cmd:"" help:"fetch OCSP from certificate"`
}

type OCSPFetchCmd

OCSPFetchCmd specifies flags to fetch OCSP

type OCSPFetchCmd struct {
    Cert  string `kong:"arg" required:"" help:"certificate file name"`
    CA    string `help:"optional, CA bundle file"`
    Out   string `help:"output folder name"`
    Proxy string `help:"optional, proxy address or DC name"`
    Print bool
}

func (*OCSPFetchCmd) Run

func (a *OCSPFetchCmd) Run(ctx *Cli) error

Run the command. Every OCSP endpoint of the certificate is queried and each failure is printed as `<url> : ERROR: <reason>`. The command succeeds when at least one endpoint returned a valid response, and fails when every endpoint failed (XPKI-102). A failure to write the response file (--out) or to parse the response for --print is returned at once.

type OCSPInfoCmd

OCSPInfoCmd specifies flags for OCSP info command

type OCSPInfoCmd struct {
    In     string `kong:"arg" required:"" help:"OCSP file name"`
    Issuer string `help:"optional, PEM file with the issuer certificate to verify the response signature"`
}

func (*OCSPInfoCmd) Run

func (a *OCSPInfoCmd) Run(ctx *Cli) error

Run the command

Generated by gomarkdoc