Package localca implements a localca that is useful for testing the transport package. To use the localca, see the New and Load functions.



This section is empty.


This section is empty.


func ExampleRequest

func ExampleRequest() *csr.CertificateRequest

ExampleRequest can be used as a sample request, or the returned request can be modified.

func ExampleSigningConfig

func ExampleSigningConfig() *config.Signing

ExampleSigningConfig returns a sample config.Signing with only a default profile.

func Load

func Load(lca *CA, profiles *config.Signing) (err error)

Load reads the key and certificate from the files specified in the CA.


type CA

type CA struct {

	// Label and Profile are used to select the CFSSL signer
	// components if they should be anything but the default.
	Label   string `json:"label"`
	Profile string `json:"profile"`

	// The KeyFile and CertFile are required when using Load to
	// construct a CA.
	KeyFile  string `json:"private_key,omitempty"`
	CertFile string `json:"certificate,omitempty"`
	// contains filtered or unexported fields

CA is a local transport CertificateAuthority that is useful for tests.

func New

func New(req *csr.CertificateRequest, profiles *config.Signing) (*CA, error)

New generates a new CA from a certificate request and signing profile.

func NewFromSigner

func NewFromSigner(s *local.Signer) *CA

NewFromSigner constructs a local CA from a CFSSL signer.

func (*CA) CACertificate

func (lca *CA) CACertificate() ([]byte, error)

CACertificate returns the certificate authority's certificate.

func (*CA) SignCSR

func (lca *CA) SignCSR(csrPEM []byte) ([]byte, error)

SignCSR submits a PKCS #10 certificate signing request to a CA for signing.

func (*CA) Toggle

func (lca *CA) Toggle()

Toggle switches the CA between operable mode and inoperable mode. This is useful in testing to verify behaviours when a CA is unavailable.

Source Files