client

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RSA2048  = "rsa:2048"
	RSA3072  = "rsa:3072"
	RSA4096  = "rsa:4096"
	ECDSA224 = "ecdsa:224"
	ECDSA256 = "ecdsa:256"
	ECDSA384 = "ecdsa:384"
	ECDSA521 = "ecdsa:521"
)

key algorithms

Variables

View Source
var (
	ErrUnknownError      = errors.New("unknown error connecting to server")
	ErrConnectionRefused = errors.New("connection refused")
)

errors

Functions

This section is empty.

Types

type APICertificateRequest

type APICertificateRequest struct {
	DN             APIDN    `json:"dn"`
	SAN            []string `json:"san" yaml:"san"`       // SAN
	Key            string   `json:"key" yaml:"key"`       // Key Type (RSA/ECDSA):(complexity)
	ExpirationDays int64    `json:"exp" yaml:"exp"`       // Days the certificate will be valid
	Client         bool     `json:"client" yaml:"client"` // requesting a client certificate?
}

APICertificateRequest is the struct with the data needed to create a new certificate

type APIDN

type APIDN struct {
	CN string `json:"cn,omitempty" yaml:"cn"` // common name (required)
	C  string `json:"c,omitempty" yaml:"c"`   // country
	L  string `json:"l,omitempty" yaml:"l"`   // locality
	O  string `json:"o,omitempty" yaml:"o"`   // organization
	OU string `json:"ou,omitempty" yaml:"ou"` // organization unit
	P  string `json:"p,omitempty" yaml:"p"`   // province
	PC string `json:"pc,omitempty" yaml:"pc"` // postal code
	ST string `json:"st,omitempty" yaml:"st"` // street
}

APIDN is the struct of a Distinguished Name

type APIStatus

type APIStatus struct {
	Version string `json:"version"`
}

APIStatus is returned by the API on GET /status

type Certificate

type Certificate struct {
	Key             []byte                `json:"key,omitempty"`
	Certificate     []byte                `json:"certificate,omitempty"`
	CACertificate   []byte                `json:"ca_certificate,omitempty"`
	X509Certificate *x509.Certificate     `json:"-"`
	Request         APICertificateRequest `json:"request"`
	CAID            string                `json:"ca_id,omitempty"`
}

Certificate holds the certificate and key file used to interact with the data store

type Client

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

Client is the API client if the service is working in client/server mode

func New

func New(baseURL, caCert, cert, key string, useSystemCerts bool) (*Client, error)

New returns an API client with default timeout configurations baseURL = IP:PORT where it will listen for requests caCert = ca certificate to use (optional) cert = client certificate to use (optional) key = client key to use (optional) useSystemCerts = ensures connection is HTTPS using system certificates

func NewWithConnectionTimeouts

func NewWithConnectionTimeouts(baseURL, caCertPath, certPath, keyPath string, useSystemCerts bool, dialerTimeout, handshakeTimeout, timeout time.Duration) (*Client, error)

NewWithConnectionTimeouts returns a configured API client

func (*Client) CACreate

func (c *Client) CACreate(request APICertificateRequest) (response Certificate, err error)

CACreate returns status information if connection is ok to the API, error otherwise

func (*Client) CertificateCreate

func (c *Client) CertificateCreate(caID, cn string, request APICertificateRequest) (response Certificate, err error)

CertificateCreate returns status information if connection is ok to the API, error otherwise

func (*Client) CertificateDelete added in v0.2.0

func (c *Client) CertificateDelete(caID, cn string) (ok bool, err error)

CertificateDelete deletes a certificate

func (*Client) CertificateGet

func (c *Client) CertificateGet(caID, cn string, remaining int) (response Certificate, err error)

CertificateGet returns the certificate information if found

func (*Client) CertificateList added in v0.2.0

func (c *Client) CertificateList(caID string) (response map[string]Certificate, err error)

CertificateList returns the certificate information if found

func (*Client) Status

func (c *Client) Status() (status APIStatus, err error)

Status returns status information if connection is ok to the API, error otherwise

Jump to

Keyboard shortcuts

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