cert

package
v2.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 7 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(rand io.Reader, template, parent *x509.Certificate, pub, priv interface{}) ([]byte, error)

Create is a wrapper around x509.CreateCertificate, but it additionally encodes it in base64 so that it can be easily added to `x5c` fields

func EncodeBase64

func EncodeBase64(der []byte) ([]byte, error)

EncodeBase64 is a utility function to encode ASN.1 DER certificates using base64 encoding. This operation is normally done by `pem.Encode` but since PEM would include the markers (`-----BEGIN`, and the like) while `x5c` fields do not need this, this function can be used to shave off a few lines

func Parse

func Parse(src []byte) (*x509.Certificate, error)

Parse is a utility function to decode a base64 encoded ASN.1 DER format certificate, and to parse the byte sequence. The certificate must be in PKIX format, and it must not contain PEM markers

Types

type Chain

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

Chain represents a certificate chain as used in the `x5c` field of various objects within JOSE.

It stores the certificates as a list of base64 encoded []byte sequence. By definition these values must PKIX encoded.

func (*Chain) Add

func (cc *Chain) Add(der []byte) error

func (*Chain) AddString

func (cc *Chain) AddString(der string) error

func (*Chain) Get

func (cc *Chain) Get(index int) ([]byte, bool)

Get returns the n-th ASN.1 DER + base64 encoded certificate stored. `false` will be returned in the second argument if the corresponding index is out of range.

func (*Chain) Len

func (cc *Chain) Len() int

Len returns the number of certificates stored in this Chain

func (Chain) MarshalJSON

func (cc Chain) MarshalJSON() ([]byte, error)

func (*Chain) UnmarshalJSON

func (cc *Chain) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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