x509

package
v0.0.0-...-160cdcc Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientCert

func NewClientCert(key, rootKey *rsa.PrivateKey, rootCert *x509.Certificate, subject pkix.Name, ttl time.Time, w io.Writer, host ...string) (*x509.Certificate, error)

func NewPrivateKey

func NewPrivateKey(bits int, w io.Writer) (*rsa.PrivateKey, error)

NewPrivateKey will create a new private key of the given bits size, If the second argument is not nil a pem encoded block of the generated key wil be writer to that writer.

func NewRootCert

func NewRootCert(key *rsa.PrivateKey, subject pkix.Name, ttl time.Time, w io.Writer) (*x509.Certificate, error)

NewRootCert will generate a new CA cert that will be used to sign and authenticate client and servers, a pem encoded block will be written to the given writer (is it is not nil).

func NewServerCert

func NewServerCert(key, rootKey *rsa.PrivateKey, rootCert *x509.Certificate, subject pkix.Name, ttl time.Time, w io.Writer, host ...string) (*x509.Certificate, error)

func OpenCertificate

func OpenCertificate(name string) (*x509.Certificate, error)

OpenCertificate opem PEM encoded certificate file and decode data

func OpenPrivateKey

func OpenPrivateKey(name string) (*rsa.PrivateKey, error)

OpenPrivateKey reads the source file and return the private key. The source file should be contain a pem encoded private key.

Types

type DN

type DN struct {
	CN           string
	SERIALNUMBER string
	UID          string
	SN           []string
	C            []string
	L            []string
	STREET       []string
	POSTALCODE   []string
	ST           []string
	O            []string
	OU           []string
	TITLE        []string
	G            []string
	DC           []string
}

DN represents an X.509 distinguished name. It can read or copy values to a pkix.Name object that can be used for creating a certificate. The main deference between a pkix.Name and DN is that the DN can also read from a string and write to string (ReadString and String methods)

func (*DN) ReadPkixName

func (d *DN) ReadPkixName(n pkix.Name)

ReadPkixName will copy the values from a pkix.Name to this instance

func (*DN) ReadString

func (d *DN) ReadString(str string)

func (DN) ToPkixName

func (d DN) ToPkixName() (n pkix.Name)

Jump to

Keyboard shortcuts

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