pki

package
v0.32.3 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 20 Imported by: 1

Documentation

Overview

Package pki provides support for HSDP PKI service

Index

Constants

View Source
const (
	APIVersion = "1"
)

Variables

View Source
var (
	ErrBasePKICannotBeEmpty           = errors.New("base PKI URL cannot be empty")
	ErrMissingPKIPermissions          = errors.New("missing PKI permissions")
	ErrMissingIAMOrganization         = errors.New("missing IAM organization")
	ErrEmptyResult                    = errors.New("empty result")
	ErrCouldNoReadResourceAfterCreate = errors.New("could not read resource after create")
	ErrCertificateExpected            = errors.New("certificate expected")
	ErrCRLExpected                    = errors.New("certificate revocation list expected")
	ErrCFClientNotConfigured          = errors.New("CF client not configured")
	ErrCFInvalidToken                 = errors.New("invalid CF token")
	ErrInvalidPrivateKey              = errors.New("invalid private key")
	ErrNotImplementedYet              = errors.New("not implemented yet")
)

Errors

Functions

This section is empty.

Types

type CertificateAuthority

type CertificateAuthority struct {
	TTL          string `json:"ttl"`
	CommonName   string `json:"common_name" validate:"required"`
	KeyType      string `json:"key_type" validate:"required" enum:"rsa|ec"`
	KeyBits      int    `json:"key_bits"`
	OU           string `json:"ou"`
	Organization string `json:"organization"`
	Country      string `json:"country"`
	Locality     string `json:"locality"`
	Province     string `json:"province"`
}

type CertificateRequest

type CertificateRequest struct {
	CommonName        string `json:"common_name" validate:"required,max=253"`
	AltName           string `json:"alt_name,omitempty"`
	IPSANS            string `json:"ip_sans,omitempty"`
	URISANS           string `json:"uri_sans,omitempty"`
	OtherSANS         string `json:"other_sans,omitempty"`
	TTL               string `json:"ttl,omitempty"`
	Format            string `json:"format,omitempty"`
	PrivateKeyFormat  string `json:"private_key_format,omitempty"`
	ExcludeCNFromSANS *bool  `json:"exclude_cn_from_sans,omitempty"`
}

type Client

type Client struct {

	// User agent used when communicating with the HSDP IAM API.
	UserAgent string

	Tenants  *TenantService
	Services *ServicesService // Sounds like something from Java!
	// contains filtered or unexported fields
}

A Client manages communication with HSDP PKI API

func NewClient

func NewClient(consoleClient *console.Client, iamClient *iam.Client, config *Config) (*Client, error)

NewClient returns a new HSDP PKI API client. Configured console and IAM clients must be provided as the underlying API requires tokens from respective services

func (*Client) Close

func (c *Client) Close()

Close releases allocated resources of clients

func (*Client) SetBasePKIURL

func (c *Client) SetBasePKIURL(urlStr string) error

SetBasePKIURL sets the base URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.

type Config

type Config struct {
	Region      string
	Environment string
	PKIURL      string
	UAAURL      string
	Debug       bool
	DebugLog    string
}

Config contains the configuration of a client

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response `json:"-"`
	Code     string         `json:"responseCode"`
	Message  string         `json:"responseMessage"`
	Errors   []string       `json:"errors,omitempty"`
}

ErrorResponse represents an IAM errors response containing a code and a human readable message

func (*ErrorResponse) Error added in v0.30.0

func (e *ErrorResponse) Error() string

type IssueData

type IssueData struct {
	CaChain        []string `json:"ca_chain"`
	Certificate    string   `json:"certificate"`
	Expiration     int      `json:"expiration"`
	IssuingCa      string   `json:"issuing_ca"`
	PrivateKey     string   `json:"private_key"`
	PrivateKeyType string   `json:"private_key_type"`
	SerialNumber   string   `json:"serial_number"`
}

func (*IssueData) GetCertificate

func (d *IssueData) GetCertificate() (*x509.Certificate, error)

func (*IssueData) GetPrivateKey

func (d *IssueData) GetPrivateKey() (interface{}, error)

type IssueResponse

type IssueResponse struct {
	RequestID     string    `json:"request_id"`
	LeaseID       string    `json:"lease_id"`
	Renewable     bool      `json:"renewable"`
	LeaseDuration int       `json:"lease_duration"`
	Data          IssueData `json:"data"`
	WrapInfo      *string   `json:"wrap_info"`
	Warnings      *string   `json:"warnings"`
	Auth          *string   `json:"auth"`
}

type OnboardingResponse

type OnboardingResponse struct {
	APIEndpoint string `json:"api_endpoint"`
}

type OptionFunc

type OptionFunc func(*http.Request) error

OptionFunc is the function signature function for options

type Response

type Response struct {
	*http.Response
}

Response is a HSDP IAM API response. This wraps the standard http.Response returned from HSDP IAM and provides convenient access to things like errors

type Role

type Role struct {
	Name                 string   `json:"name" validate:"required"`
	AllowAnyName         bool     `json:"allow_any_name" validate:"required"`
	AllowIPSans          bool     `json:"allow_ip_sans" validate:"required"`
	AllowSubdomains      bool     `json:"allow_subdomains" validate:"required"`
	AllowedDomains       []string `json:"allowed_domains"`
	AllowedOtherSans     []string `json:"allowed_other_sans"`
	AllowedSerialNumbers []string `json:"allowed_serial_numbers"`
	AllowedURISans       []string `json:"allowed_uri_sans"`
	ClientFlag           bool     `json:"client_flag" validate:"required"`
	Country              []string `json:"country"`
	EnforceHostnames     bool     `json:"enforce_hostnames" validate:"required"`
	KeyBits              int      `json:"key_bits"`
	KeyType              string   `json:"key_type"`
	Locality             []string `json:"locality"`
	MaxTTL               string   `json:"max_ttl"`
	NotBeforeDuration    string   `json:"not_before_duration"`
	Organization         []string `json:"organization"`
	OU                   []string `json:"ou"`
	PostalCode           []string `json:"postal_code"`
	Province             []string `json:"province"`
	ServerFlag           bool     `json:"server_flag"`
	StreetAddress        []string `json:"street_address"`
	TTL                  string   `json:"ttl"`
	UseCSRCommonName     bool     `json:"use_csr_common_name"`
	UseCSRSans           bool     `json:"use_csr_sans"`
}

type ServiceOptions

type ServiceOptions struct {
}

ServiceOptions

type ServiceParameters

type ServiceParameters struct {
	LogicalPath string               `json:"logical_path,omitempty"`
	IAMOrgs     []string             `json:"iam_orgs" validate:"min=1,max=10,required"`
	CA          CertificateAuthority `json:"ca" validate:"required"`
	Roles       []Role               `json:"roles" validate:"min=1,max=10,required"`
}

type ServicesService

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

func (*ServicesService) GetCertificateBySerial

func (c *ServicesService) GetCertificateBySerial(logicalPath, serial string, options ...OptionFunc) (*IssueResponse, *Response, error)

GetCertificateBySerial

func (*ServicesService) GetPolicyCA

func (c *ServicesService) GetPolicyCA(options ...OptionFunc) (*x509.Certificate, *Response, error)

GetPolicyCA

func (*ServicesService) GetPolicyCRL

func (c *ServicesService) GetPolicyCRL(options ...OptionFunc) (*pkix.CertificateList, *Response, error)

GetPolicyCRL

func (*ServicesService) GetRootCA

func (c *ServicesService) GetRootCA(options ...OptionFunc) (*x509.Certificate, *Response, error)

GetRootCA

func (*ServicesService) GetRootCRL

func (c *ServicesService) GetRootCRL(options ...OptionFunc) (*pkix.CertificateList, *Response, error)

GetRootCRL

func (*ServicesService) IssueCertificate

func (c *ServicesService) IssueCertificate(logicalPath, roleName string, request CertificateRequest, options ...OptionFunc) (*IssueResponse, *Response, error)

IssueCertificate

func (*ServicesService) Sign

func (c *ServicesService) Sign(logicalPath, roleName string, signRequest SignRequest, options ...OptionFunc) (*IssueResponse, *Response, error)

Sign

type SignRequest

type SignRequest struct {
	CSR               string `json:"csr" validation:"required"`
	CommonName        string `json:"common_name" validation:"required"`
	AltNames          string `json:"alt_names"`
	OtherSans         string `json:"other_sans"`
	IPSans            string `json:"ip_sans"`
	URISans           string `json:"uri_sans"`
	TTL               string `json:"ttl,omitempty"`
	Format            string `json:"format" validation:"required"  enum:"pem|der|pem_bundle"`
	ExcludeCNFromSans bool   `json:"exclude_cn_from_sans"`
}

SignRequest

type Tenant

type Tenant struct {
	OrganizationName  string            `json:"organization_name" validate:"required"`
	SpaceName         string            `json:"space_name" validate:"required"`
	ServiceName       string            `json:"service_name" validate:"required"`
	PlanName          string            `json:"plan_name" validate:"required"`
	ServiceParameters ServiceParameters `json:"service_parameters" validate:"required"`
}

type TenantService

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

func (*TenantService) Offboard

func (t *TenantService) Offboard(tenant Tenant, options ...OptionFunc) (bool, *Response, error)

func (*TenantService) Onboard

func (t *TenantService) Onboard(tenant Tenant, options ...OptionFunc) (*OnboardingResponse, *Response, error)

func (*TenantService) Retrieve

func (t *TenantService) Retrieve(logicalPath string, options ...OptionFunc) (*Tenant, *Response, error)

func (*TenantService) Update

func (t *TenantService) Update(tenant Tenant, options ...OptionFunc) (bool, *Response, error)

Jump to

Keyboard shortcuts

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