util

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package util is originated from https://github.com/yahoo/k8s-athenz-identity/tree/ae7c7ef/pkg/util

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertificateFromPEMBytes

func CertificateFromPEMBytes(pemBytes []byte) (*x509.Certificate, error)

CertificateFromPEMBytes returns an X.509 certificate from its supplied PEM representation.

func GenerateCSR

func GenerateCSR(signer crypto.Signer, opts CSROptions) (csrPEM []byte, err error)

GenerateCSR generates a CSR using the supplied key, common name and options.

func GenerateKeyAndCSR

func GenerateKeyAndCSR(opts CSROptions) (keyPEM, csrPEM []byte, err error)

GenerateKeyAndCSR generates a private key and returns the key and CSR PEMs.

func MarshalSANs

func MarshalSANs(sans SubjectAlternateNames) (pkix.Extension, error)

func PublicKeyFromPEMBytes

func PublicKeyFromPEMBytes(pemBytes []byte) (crypto.PublicKey, error)

PublicKeyFromPEMBytes returns a public key from its supplied PEM representation.

Types

type CSROptions

type CSROptions struct {
	Subject pkix.Name
	SANs    SubjectAlternateNames
}

CSROptions has optional config for creating a CSR request

type KeyType

type KeyType int

KeyType is the type of private key.

const (
	RSA KeyType
	ECDSA
)

supported key types

func PrivateKeyFromPEMBytes

func PrivateKeyFromPEMBytes(privatePEMBytes []byte) (KeyType, crypto.Signer, error)

PrivateKeyFromPEMBytes returns a private key along with its type from its supplied PEM representation.

type SubjectAlternateNames

type SubjectAlternateNames struct {
	DNSNames       []string
	IPAddresses    []net.IP
	URIs           []url.URL
	EmailAddresses []string
}

SubjectAlternateNames contains the SAN entities in a cert.

func UnmarshalSANs

func UnmarshalSANs(extensions []pkix.Extension) (sans SubjectAlternateNames, err error)

func (*SubjectAlternateNames) IsEmpty

func (s *SubjectAlternateNames) IsEmpty() bool

func (SubjectAlternateNames) String

func (s SubjectAlternateNames) String() string

type Writer

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

Writer writes multiple files with modified suffixes and renames all of them to their final names on save.

func NewWriter

func NewWriter() *Writer

NewWriter returns a writer.

func (*Writer) AddBytes

func (w *Writer) AddBytes(target string, perms os.FileMode, content []byte) error

AddBytes writes a file with the supplied bytes.

func (*Writer) AddFile

func (w *Writer) AddFile(target string, perms os.FileMode, source string) error

AddFile writes a file using the supplied file as source.

func (*Writer) AddReader

func (w *Writer) AddReader(target string, perms os.FileMode, content io.Reader) error

AddReader writes a file using the supplied reader as source.

func (*Writer) Save

func (w *Writer) Save() error

Save renames all temp files written to their final names. When multiple files are involved, this reduces race conditions with inconsistent data but does not completely eliminate it.

Jump to

Keyboard shortcuts

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