crypto

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCAPath = fmt.Errorf("no path provided")

Functions

This section is empty.

Types

type Client

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

func New

func New(c *config.Config) *Client

func (*Client) CACertificateFilePath

func (c *Client) CACertificateFilePath(caDir string) (string, error)

CACertificateFilePath returns the CA certificate path based on caDir.

func (*Client) CAPrivKeyFilePath

func (c *Client) CAPrivKeyFilePath(caDir string) (string, error)

CAPrivKeyFilePath returns the CA privkey path based on caDir.

func (*Client) CheckCACertificateExistInDir

func (c *Client) CheckCACertificateExistInDir(caDir string, dontAskRecreate ...bool) bool

CheckCACertificateExistInDir checks if the CA Certificate PEM file already exists in Dir.

func (*Client) CreateCACertificate

func (c *Client) CreateCACertificate(caDir string) error

CreateCACertificate creates a Private Key and a Signed CA Certificate in PEM format and writes to file.

func (*Client) CreatePrivateKeyAndCertificate

func (c *Client) CreatePrivateKeyAndCertificate(
	certificateDir, certificateName string,
	dnsNames []string, caCertificateFilePath, caPrivateKeyFilePath string,
) error

CreatePrivateKeyAndCertificate creates a Private Key and a Certificate signed by caCertificate and writes to file in PEM format.

func (*Client) EncodeRSAPrivateKeyToPEM

func (c *Client) EncodeRSAPrivateKeyToPEM(privateKey *rsa.PrivateKey) ([]byte, error)

EncodeRSAPrivateKeyToPEM encodes Private Key from RSA to PEM format.

func (*Client) GenerateSSHKeys

func (c *Client) GenerateSSHKeys(bitSize int, path string) error

GenerateSSHKeys generates and writes SSH keys with bitSize and saves them to path.

func (*Client) GenerateSSHPublicKey

func (c *Client) GenerateSSHPublicKey(publicKey *rsa.PublicKey) ([]byte, error)

GenerateSSHPublicKey takes a rsa.PublicKey and return bytes suitable for writing to .pub file returns in the format "ssh-rsa ...".

func (*Client) InstallCACertificate

func (c *Client) InstallCACertificate(caDir string) error

InstallCACertificate installs the generated CA certificate.

Jump to

Keyboard shortcuts

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