util

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegistrationEntries

func GetRegistrationEntries(fileName string) []*common.RegistrationEntry

GetRegistrationEntries gets registration entries from a fixture

func GetRegistrationEntriesMap

func GetRegistrationEntriesMap(fileName string) map[string][]*common.RegistrationEntry

GetRegistrationEntriesMap gets a map of registration entries from a fixture

func LoadBundle

func LoadBundle(path string) ([]*x509.Certificate, error)

func LoadBundleFixture

func LoadBundleFixture() ([]*x509.Certificate, error)

func LoadCAFixture

func LoadCAFixture() (ca *x509.Certificate, key *ecdsa.PrivateKey, err error)

LoadCAFixture reads, parses, and returns the pre-defined CA fixture and key

func LoadCert

func LoadCert(path string) (*x509.Certificate, error)

LoadCert reads and parses an X.509 certificate at the specified path

func LoadCertAndKey

func LoadCertAndKey(crtPath, keyPath string) (*x509.Certificate, *ecdsa.PrivateKey, error)

LoadCertAndKey reads and parses both a certificate and a private key at once

func LoadKey

func LoadKey(path string) (*ecdsa.PrivateKey, error)

LoadKey reads and parses the ECDSA private key at the specified path

func LoadPEM

func LoadPEM(path string) (*pem.Block, error)

LoadPEM reads and parses the PEM structure at the specified path

func LoadSVIDFixture

func LoadSVIDFixture() (svid *x509.Certificate, key *ecdsa.PrivateKey, err error)

LoadSVIDFixture reads, parses, and returns the pre-defined SVID fixture and key

func NewCATemplate

func NewCATemplate(clk clock.Clock, trustDomain spiffeid.TrustDomain) (*x509.Certificate, error)

NewCATemplate returns a default CA template with the specified trust domain. Must be signed before it's valid.

func NewCSRTemplate

func NewCSRTemplate(spiffeID string) ([]byte, crypto.PublicKey, error)

NewCSRTemplate returns a default CSR template with the specified SPIFFE ID.

func NewCSRTemplateWithKey

func NewCSRTemplateWithKey(spiffeID string, key crypto.Signer) ([]byte, error)

func NewSVIDTemplate

func NewSVIDTemplate(clk clock.Clock, spiffeID string) (*x509.Certificate, error)

NewSVIDTemplate returns a default SVID template with the specified SPIFFE ID. Must be signed before it's valid.

func NewSVIDTemplateFromCSR

func NewSVIDTemplateFromCSR(clk clock.Clock, csr []byte, ca *x509.Certificate, ttl int) (*x509.Certificate, error)

func ProjectRoot

func ProjectRoot() string

ProjectRoot returns the absolute path to the SPIRE project root

func RaceTest

func RaceTest(t *testing.T, fn func(*testing.T))

func RunWithTimeout

func RunWithTimeout(t *testing.T, timeout time.Duration, code func()) time.Duration

RunWithTimeout runs code within the specified timeout, if execution takes longer than that, an error is logged to t with information about the caller of this function. Returns how much time it took to run the function.

func SelfSign

func SelfSign(req *x509.Certificate) (*x509.Certificate, *ecdsa.PrivateKey, error)

SelfSign creates a new self-signed certificate with the provided template.

func Sign

func Sign(req, parent *x509.Certificate, signerPrivateKey interface{}) (*x509.Certificate, *ecdsa.PrivateKey, error)

Sign creates a new certificate based on the provided template and signed using parent certificate and signerPrivateKey.

Types

type OutputRedirection

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

func (*OutputRedirection) Finish

func (redirector *OutputRedirection) Finish() (string, error)

func (*OutputRedirection) Start

func (redirector *OutputRedirection) Start(output *os.File) error

Jump to

Keyboard shortcuts

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