certtool

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package certtool is the public interface for integrating with auto generating certificates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseName

func ParseName(subject string) (pkix.Name, error)

ParseName parses the RFC-2253 encoded Distinguished Names.

func ReadKeyPair

func ReadKeyPair(publicCertFileData []byte, privateKeyFileData []byte) (*x509.Certificate, interface{}, error)

ReadKeyPair takes PEM-encoded public certificate/private key pairs and returns the Go classes for them so they can be used for encryption or signing.

func WriteKeyPair

func WriteKeyPair(kp *KeyPair, publicCertificateFile string, privateKeyFile string) error

Types

type Args

type Args struct {
	// CA indicates we need to create a CA certificate.
	CA bool

	// CommonName
	CommonName string
	// Country of the entity representing the certificate.
	Country string
	// Organization of the entity representing the certificate.
	Organization string
	// OrganizationalUnit of the entity representing the certificate.
	OrganizationalUnit string
	// Locality of the entity representing the certificate.
	Locality string
	// Province (or state) of the entity representing the certificate.
	Province string

	// Hostnames is a list of hostname (optional :port) of the endpoint used by the certificate.
	Hostnames []string
	// Validity is how long the certificate should be valid for.
	Validity time.Duration
	// ParentKeyPair is the root public certificate within the chain of trust.
	ParentKeyPair *KeyPair

	// KeyType is the type of key to generate.
	KeyType *KeyType
}

Args of creating a self-signed X.509 public certificate/private key pair.

func (*Args) GetKeyType

func (args *Args) GetKeyType() *KeyType

type KeyPair

type KeyPair struct {
	// PublicCertificate of the X.509 key pair.
	PublicCertificate []byte
	// PrivateKey of the X.509 key pair.
	PrivateKey []byte
}

KeyPair is the X.509 public certificate/private key pair

func GenerateAndWriteKeyPair

func GenerateAndWriteKeyPair(args *Args, publicCertificateFile string, privateKeyFile string) (*KeyPair, error)

func GenerateKeyPair

func GenerateKeyPair(args *Args) (*KeyPair, error)

func ReadKeyPairFromFile

func ReadKeyPairFromFile(publicCertificateFile string, privateKeyFile string) (*KeyPair, error)

ReadKeyPairFromFile is a convenience method for loading the key pair from a file.

type KeyType

type KeyType struct {
	// Algorithm of the encryption
	Algorithm string
	// KeyLength is the length in bytes of the key.
	KeyLength int
}

KeyType is the key descriptor.

Jump to

Keyboard shortcuts

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