go_certcentral

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: Apache-2.0 Imports: 12 Imported by: 1

README

go-certcentral

GoLang client for the DigiCert cert-central services API.

Usage

import certcentral "github.com/sapcc/go-certcentral"

client, err := cc.New(&cc.Options{
  Token: "DIGICERT_API_TOKEN",
  IsDebug: false,
})
handleError(err)

// Submit a certificate order.
orderResponse, err := cli.SubmitOrder(
  cc.Order{
    Certificate: cc.Certificate{
      CommonName:     csr.Subject.CommonName,
      DNSNames:       csr.DNSNames,
      CSR:            csrPEM,
      ServerPlatform: cc.ServerPlatformForType(cc.ServerPlatformTypes.Nginx),
      SignatureHash:  cc.SignatureHashes.SHA256,
      CaCertID:       "CACertID",
      OrganizationUnits: []string{
        "SomeOrganization ",
      },
    },
    ValidityYears:               1,
    DisableRenewalNotifications: true,
    PaymentMethod:               cc.PaymentMethods.Balance,
    SkipApproval:                true,
    Organization:                &cc.Organization{ID: 123456},
}, cc.OrderTypes.PrivateSSLPlus)
handleError(err)

// If auto-approval is allowed the response contains the full chain of certificates in PEM format. 
if len(orderResponse.CertificateChain) > 0 {
  crtChain, err := orderResponse.DecodeCertificateChain()
  handleError(err)

  for _, crt := range crtChain {
    fmt.Println(crt.Subject.CommonName)
  }
}

// Download the certificate(s) for an order.
certList, err := client.DownloadCertificateForOrder("123456", cc.CertificateFormats.PEMAll)
handlerError(err)
for _, cert := range certList {
  fmt.Println(cert.Subject.CommonName)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CertificateFormats = struct {
	Default,
	PEM,
	DefaultPEM,
	PEMAll,
	PEMNoIntermediate,
	PEMNoRoot,
	P7B,
	CRT CertificateFormat
}{
	"default",
	"pem",
	"default_pem",
	"pem_all",
	"pem_nointermediate",
	"pem_noroot",
	"p7b",
	"crt",
}

CertificateFormats is the set of formats for a certificate. Additional documentation can be found here: https://dev.digicert.com/glossary/#certificate-formats

View Source
var OrderTypes = struct {
	SSLPlus,
	PrivateSSLPlus,
	PrivateSSLWildcard OrderType
}{
	"ssl_plus",
	"private_ssl_plus",
	"private_ssl_wildcard",
}
View Source
var PaymentMethods = struct {
	Balance,
	Card,
	Profile,
	WireTransfer PaymentMethod
}{
	"balance",
	"card",
	"profile",
	"wire_transfer",
}
View Source
var ServerPlatformTypes = struct {
	Nginx,
	Other ServerPlatformType
}{
	45,
	57,
}

ServerPlatformTypes is the collection of available ServerPlatformType. The full list of supported server platforms can be found here: https://www.digicert.com/services/v2/documentation/appendix-server-platforms

View Source
var SignatureHashes = struct {
	SHA256,
	SHA384,
	SHA512,
	SHA1 SignatureHash
}{
	"sha256",
	"sha384",
	"sha512",
	"sha1",
}
View Source
var Stati = struct {
	Pending,
	Approved,
	Rejected Status
}{
	"pending",
	"approved",
	"rejected",
}

Functions

This section is empty.

Types

type CACert

type CACert struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Certificate

type Certificate struct {
	CommonName        string         `json:"common_name"`
	DNSNames          []string       `json:"dns_names"`
	CSR               string         `json:"csr,omitempty"`
	ServerPlatform    ServerPlatform `json:"server_platform"`
	SignatureHash     SignatureHash  `json:"signature_hash"`
	CaCertID          string         `json:"ca_cert_id,omitempty"`
	OrganizationUnits []string       `json:"organization_units,omitempty"`
	Organization      *Organization  `json:"organization,omitempty"`
	ProfileOption     string         `json:"profile_option,omitempty"`
	ID                int            `json:"id,omitempty"`
	Thumbprint        string         `json:"thumbprint,omitempty"`
	SerialNumber      string         `json:"serial_number,omitempty"`
	DateCreated       *time.Time     `json:"date_created,omitempty"`
	ValidFrom         string         `json:"valid_from,omitempty"`
	ValidTill         string         `json:"valid_till,omitempty"`
	KeySize           int            `json:"key_size,omitempty"`
	CACert            *CACert        `json:"ca_cert,omitempty"`
}

type CertificateChain

type CertificateChain struct {
	SubjectCommonName string `json:"subject_common_name"`
	Pem               string `json:"pem"`
}

func (CertificateChain) DecodePEM

func (cc CertificateChain) DecodePEM() ([]*x509.Certificate, error)

type CertificateFormat

type CertificateFormat string

func (CertificateFormat) String

func (cf CertificateFormat) String() string

type CertificateRevokeResponse

type CertificateRevokeResponse struct {
	ID        int        `json:"id"`
	Date      *time.Time `json:"date,omitempty"`
	Type      string     `json:"type,omitempty"`
	Status    Status     `json:"status,omitempty"`
	Requester *User      `json:"requester,omitempty"`
	Comments  string     `json:"comments,omitempty"`
}

type Client

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

Client is the client for the DigiCert cert-central API.

func New

func New(opts *Options) (*Client, error)

func (*Client) DownloadCertificate

func (c *Client) DownloadCertificate(certificateID string, certFormat CertificateFormat) ([]*x509.Certificate, error)

func (*Client) DownloadCertificateForOrder

func (c *Client) DownloadCertificateForOrder(orderID string, certFormat CertificateFormat) ([]*x509.Certificate, error)

func (*Client) GetDomain

func (c *Client) GetDomain(domainID string) (*Domain, error)

func (*Client) GetOrder

func (c *Client) GetOrder(orderID string) (*Order, error)

func (*Client) GetOrganization

func (c *Client) GetOrganization(organizationID string) (*Organization, error)

func (*Client) GetOrganizationByName

func (c *Client) GetOrganizationByName(organizationName string) (*Organization, error)

func (*Client) ListDomains

func (c *Client) ListDomains(containerID string) ([]Domain, error)

func (*Client) ListOrganizations

func (c *Client) ListOrganizations() ([]Organization, error)

func (*Client) ListProducts

func (c *Client) ListProducts() ([]Product, error)

func (*Client) RevokeCertificate

func (c *Client) RevokeCertificate(certificateID string) (*CertificateRevokeResponse, error)

func (*Client) SubmitOrder

func (c *Client) SubmitOrder(order Order, orderType OrderType) (*Order, error)

type Container

type Container struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	IsActive bool   `json:"is_active"`
}

type DCV

type DCV struct {
	Method         string           `json:"method,omitempty"`
	NameScope      string           `json:"name_scope,omitempty"`
	DcvInvitations []DCVInvitations `json:"dcv_invitations,omitempty"`
}

type DCVInvitations

type DCVInvitations []struct {
	InvitationID int       `json:"invitation_id"`
	Email        string    `json:"email,omitempty"`
	Source       string    `json:"source,omitempty"`
	DateSent     time.Time `json:"date_sent,omitempty"`
	NameScope    string    `json:"name_scope,omitempty"`
}

type Domain

type Domain struct {
	ID           int           `json:"id"`
	Name         string        `json:"name"`
	IsActive     bool          `json:"is_active,omitempty"`
	DateCreated  *time.Time    `json:"date_created,omitempty"`
	Organization *Organization `json:"organization,omitempty"`
	Validations  []Validation  `json:"validations,omitempty"`
	DCV          *DCV          `json:"dcv,omitempty"`
	Container    *Container    `json:"container,omitempty"`
}

type Error

type Error struct {
	Code    int    `json:"-"`
	Status  string `json:"code"`
	Message string `json:"message"`
}

func (Error) Error

func (e Error) Error() string

type Options

type Options struct {
	Token   string
	IsDebug bool
}

type Order

type Order struct {
	Certificate                 Certificate        `json:"certificate,omitempty"`
	Organization                *Organization      `json:"organization,omitempty"`
	ValidityYears               int                `json:"validity_years,omitempty"`
	CustomExpirationDate        string             `json:"custom_expiration_date,omitempty"`
	Comments                    string             `json:"comments,omitempty"`
	ProcessorComment            string             `json:"processor_comment,omitempty"`
	DisableRenewalNotifications bool               `json:"disable_renewal_notifications,omitempty"`
	RenewalOfOrderID            int                `json:"renewal_of_order_id,omitempty"`
	PaymentMethod               PaymentMethod      `json:"payment_method,omitempty"`
	SkipApproval                bool               `json:"skip_approval,omitempty"`
	Product                     *Product           `json:"product,omitempty"`
	OrganizationContact         *User              `json:"organization_contact,omitempty"`
	TechnicalContact            *User              `json:"technical_contact,omitempty"`
	User                        *User              `json:"user,omitempty"`
	CsProvisioningMethod        string             `json:"cs_provisioning_method,omitempty"`
	DisableCT                   bool               `json:"disable_ct,omitempty"`
	Requests                    []OrderRequest     `json:"requests,omitempty"`
	ID                          int                `json:"id"`
	Domains                     []Domain           `json:"domains,omitempty"`
	CertificateID               int                `json:"certificate_id,omitempty"`
	CertificateChain            []CertificateChain `json:"certificate_chain,omitempty"`
}

func (Order) DecodeCertificateChain

func (o Order) DecodeCertificateChain() ([]*x509.Certificate, error)

type OrderRequest

type OrderRequest struct {
	ID       int        `json:"id"`
	Date     *time.Time `json:"date,omitempty"`
	Type     string     `json:"type,omitempty"`
	Status   Status     `json:"status,omitempty"`
	Comments string     `json:"comments,omitempty"`
}

type OrderType

type OrderType string

func (OrderType) String

func (o OrderType) String() string

type Organization

type Organization struct {
	ID                  int          `json:"id"`
	Status              string       `json:"status"`
	Name                string       `json:"name"`
	AssumedName         string       `json:"assumed_name,omitempty"`
	DisplayName         string       `json:"display_name,omitempty"`
	IsActive            bool         `json:"is_active,omitempty"`
	Address             string       `json:"address"`
	Address2            string       `json:"address2,omitempty"`
	City                string       `json:"city"`
	State               string       `json:"state"`
	Zip                 string       `json:"zip"`
	Country             string       `json:"country"`
	Telephone           string       `json:"telephone,omitempty"`
	Container           *Container   `json:"container,omitempty"`
	Validations         []Validation `json:"validations,omitempty"`
	EvApprovers         []User       `json:"ev_approvers,omitempty"`
	OrganizationContact *User        `json:"organization_contact,omitempty"`
	Contacts            []User       `json:"contacts,omitempty"`
}

type PaymentMethod

type PaymentMethod string

func (PaymentMethod) String

func (p PaymentMethod) String() string

type Product

type Product struct {
	GroupName             string `json:"group_name,omitempty"`
	NameID                string `json:"name_id,omitempty"`
	Name                  string `json:"name,omitempty"`
	Type                  string `json:"type,omitempty"`
	ValidationType        string `json:"validation_type,omitempty"`
	ValidationName        string `json:"validation_name,omitempty"`
	ValidationDescription string `json:"validation_description,omitempty"`
}

type ServerPlatform

type ServerPlatform struct {
	ID         int    `json:"id"`
	Name       string `json:"name,omitempty"`
	InstallURL string `json:"install_url,omitempty"`
	CsrURL     string `json:"csr_url,omitempty"`
}

ServerPlatform ...

func ServerPlatformForType

func ServerPlatformForType(platform ServerPlatformType) ServerPlatform

type ServerPlatformType

type ServerPlatformType int

func (ServerPlatformType) Int

func (s ServerPlatformType) Int() int

type SignatureHash

type SignatureHash string

func (SignatureHash) String

func (s SignatureHash) String() string

type Status

type Status string

func (Status) String

func (o Status) String() string

type User

type User struct {
	ID          int    `json:"id"`
	FirstName   string `json:"first_name,omitempty"`
	LastName    string `json:"last_name,omitempty"`
	Email       string `json:"email,omitempty"`
	JobTitle    string `json:"job_title,omitempty"`
	Telephone   string `json:"telephone,omitempty"`
	Name        string `json:"name,omitempty"`
	ContactType string `json:"contact_type,omitempty"`
}

type Validation

type Validation struct {
	Type           string     `json:"type"`
	Name           string     `json:"name"`
	Description    string     `json:"description"`
	DateCreated    *time.Time `json:"date_created,omitempty"`
	ValidatedUntil *time.Time `json:"validated_until,omitempty"`
	Status         string     `json:"status"`
	DcvStatus      string     `json:"dcv_status,omitempty"`
	VerifiedUsers  []User     `json:"verified_users,omitempty"`
}

Jump to

Keyboard shortcuts

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