Documentation
¶
Overview ¶
Package pki provides support for HSDP PKI service
Index ¶
- Constants
- Variables
- type CertificateAuthority
- type CertificateRequest
- type Client
- func (c *Client) Close()
- func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewServiceRequest(method, path string, opt interface{}, options []OptionFunc) (*http.Request, error)
- func (c *Client) NewTenantRequest(method, path string, opt interface{}, options []OptionFunc) (*http.Request, error)
- func (c *Client) SetBasePKIURL(urlStr string) error
- type Config
- type ErrorResponse
- type IssueData
- type IssueResponse
- type OnboardingResponse
- type OptionFunc
- type Response
- type Role
- type ServiceOptions
- type ServiceParameters
- type ServicesService
- func (c *ServicesService) GetCertificateBySerial(logicalPath, serial string, options ...OptionFunc) (*IssueResponse, *Response, error)
- func (c *ServicesService) GetPolicyCA(options ...OptionFunc) (*x509.Certificate, *Response, error)
- func (c *ServicesService) GetPolicyCRL(options ...OptionFunc) (*pkix.CertificateList, *Response, error)
- func (c *ServicesService) GetRootCA(options ...OptionFunc) (*x509.Certificate, *Response, error)
- func (c *ServicesService) GetRootCRL(options ...OptionFunc) (*pkix.CertificateList, *Response, error)
- func (c *ServicesService) IssueCertificate(logicalPath, roleName string, request CertificateRequest, ...) (*IssueResponse, *Response, error)
- func (c *ServicesService) Sign(logicalPath, roleName string, signRequest SignRequest, options ...OptionFunc) (*IssueResponse, *Response, error)
- type SignRequest
- type Tenant
- type TenantService
- func (t *TenantService) Offboard(tenant Tenant, options ...OptionFunc) (bool, *Response, error)
- func (t *TenantService) Onboard(tenant Tenant, options ...OptionFunc) (*OnboardingResponse, *Response, error)
- func (t *TenantService) Retrieve(logicalPath string, options ...OptionFunc) (*Tenant, *Response, error)
- func (t *TenantService) Update(tenant Tenant, options ...OptionFunc) (bool, *Response, error)
Constants ¶
const (
APIVersion = "1"
)
Variables ¶
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) Do ¶
Do executes a http request. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) NewServiceRequest ¶
func (c *Client) NewServiceRequest(method, path string, opt interface{}, options []OptionFunc) (*http.Request, error)
NewServiceRequest creates an new PKI Service API request. A relative URL path can be provided in urlStr, in which case it is resolved relative to the base URL of the Client. Relative URL paths should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Client) NewTenantRequest ¶
func (c *Client) NewTenantRequest(method, path string, opt interface{}, options []OptionFunc) (*http.Request, error)
NewTenantRequest creates an new PKI Tenant API request. A relative URL path can be provided in urlStr, in which case it is resolved relative to the base URL of the Client. Relative URL paths should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Client) SetBasePKIURL ¶
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 {
Errors []string `json:"errors,omitempty"`
}
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 ¶
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 ¶
OptionFunc is the function signature function for options
type 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 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)