cert

package
v1.4.15 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ED25519 keyType
	RSA2048
	P224
	P256
	P384
	P521
)

Variables

This section is empty.

Functions

func SerialNumber

func SerialNumber() *big.Int

Create a new serial number for the certificate, or nil if there was an error

Types

type Cert

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

Cert represents a certificate with a private key which can be used for signing other certificates

func NewCA

func NewCA(commonName string, opt ...Opt) (*Cert, error)

Create a new certificate authority with the given options

func NewCert

func NewCert(commonName string, ca *Cert, opt ...Opt) (*Cert, error)

Create a new certificate, either self-signed (if ca is nil) or signed by the certificate authority with the given options

func NewFromBytes

func NewFromBytes(data []byte) (*Cert, error)

Import certificate from byte stream

func (*Cert) Expires

func (c *Cert) Expires() time.Time

func (*Cert) IsCA

func (c *Cert) IsCA() bool

func (*Cert) IsValid

func (c *Cert) IsValid() error

func (*Cert) KeyType

func (c *Cert) KeyType() string

Return the key type

func (*Cert) MarshalJSON

func (c *Cert) MarshalJSON() ([]byte, error)

func (*Cert) Serial

func (c *Cert) Serial() string

func (*Cert) String

func (c *Cert) String() string

func (*Cert) Subject

func (c *Cert) Subject() string

func (*Cert) WriteCertificate

func (c *Cert) WriteCertificate(w io.Writer) error

Write a .pem file with the certificate

func (*Cert) WritePrivateKey

func (c *Cert) WritePrivateKey(w io.Writer) error

Write a .pem file with the private key

type Opt

type Opt func(*opts) error

func OptExpiry

func OptExpiry(years, months, days int) Opt

Set certificate expiry

func OptHosts

func OptHosts(v ...string) Opt

Set host or IP address restrictions

func OptKeyType

func OptKeyType(v string) Opt

Set private key type

func OptSerial

func OptSerial(serial int64) Opt

Set Serial number

func OptX509Name

func OptX509Name(v pkix.Name) Opt

Set X509 name

Jump to

Keyboard shortcuts

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