cmd

package
v0.0.0-...-23a808a Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultExtKeyUsageCA    = make([]x509.ExtKeyUsage, 0)
	DefaultExtKeyUsageNonCA = []x509.ExtKeyUsage{
		x509.ExtKeyUsageServerAuth,
		x509.ExtKeyUsageClientAuth,
	}
)
View Source
var RootCmd = &cobra.Command{
	SilenceUsage: true,
	Use:          "xca",
	Short:        "A simple certificate and CA tool",
	Long: `xca - Xianic Certificate Authority:

This tool is to create and sign certificates. For example to create a CA and
issue a leaf certificate run:
  xca ca init
  xca gen key leaf.key
  xca gen csr --host example.com leaf.key leaf.csr
  xca ca sign leaf.csr
`,
}

Functions

func AddLateInit

func AddLateInit(f func())

func Execute

func Execute()

func RunLateInit

func RunLateInit()

Types

type CertFlags

type CertFlags struct {
	IsCa          bool
	MaxPathLength int

	Subject string

	Lifetime uint
	Predate  time.Duration

	KeyUsages    string
	ExtKeyUsages string

	// Subject Alternate Names
	DnsSans []string
	IpSans  []string

	// Name Constraints
	PermittedDNSDomains     []string
	ExcludedDNSDomains      []string
	PermittedIPRanges       []string
	ExcludedIPRanges        []string
	PermittedEmailAddresses []string
	ExcludedEmailAddresses  []string
	PermittedURIDomains     []string
	ExcludedURIDomains      []string
}

func (*CertFlags) CheckPopulate

func (f *CertFlags) CheckPopulate() error

func (*CertFlags) Init

func (f *CertFlags) Init(fs *flag.FlagSet, ct CertFlagsType)

Init creates flags for customising certificate generation to a command. Not all flags are valid in all situations so CertFlagsType controls which flags will be created

+-----------------------------+--------------------------------------------+
| Value of ct (CertFlagsType) | Will create flags for adjusting a ...      |
+-----------------------------+--------------------------------------------+
| CertFlagsCACert             | ... CA certificate                         |
| CertFlagsSelfSign           | ... self-signed certificate                |
| CertFlagsSign               | ... certificate about to be signed by a CA |
| CertFlagsCsr                | ... CSR being generated                    |
+-----------------------------+--------------------------------------------+

func (*CertFlags) PopulateCert

func (f *CertFlags) PopulateCert(cert *x509.Certificate) error

func (*CertFlags) PopulateCsr

func (f *CertFlags) PopulateCsr(csr *x509.CertificateRequest) error

type CertFlagsType

type CertFlagsType int
const (
	CertFlagsCACert CertFlagsType = iota
	CertFlagsSelfSign
	CertFlagsSign
	CertFlagsCsr

	DefaultKeyUsageCA    = x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign | x509.KeyUsageCRLSign
	DefaultKeyUsageNonCA = x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment
)

type PemDecryptionFlags

type PemDecryptionFlags struct {
	KeyPassword PromptFlag
}

func (*PemDecryptionFlags) Init

func (f *PemDecryptionFlags) Init(fs *flag.FlagSet)

func (*PemDecryptionFlags) ParseForDecryption

func (f *PemDecryptionFlags) ParseForDecryption() *pemcrypt.CryptOptions

type PemEncryptionFlags

type PemEncryptionFlags struct {
	PemDecryptionFlags
	ArgonParams string
	YkSlot      int
}

func (*PemEncryptionFlags) Init

func (f *PemEncryptionFlags) Init(fs *flag.FlagSet)

func (*PemEncryptionFlags) ParseForEncryption

func (f *PemEncryptionFlags) ParseForEncryption() (*pemcrypt.CryptOptions, error)

type PromptFlag

type PromptFlag string

func (*PromptFlag) Init

func (f *PromptFlag) Init(fs *flag.FlagSet, longName, shortName, defaultValue, forDesc string)

func (*PromptFlag) IsSet

func (f *PromptFlag) IsSet() bool

func (*PromptFlag) Prompt

func (f *PromptFlag) Prompt() prompt.PasswordPrompt

Jump to

Keyboard shortcuts

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