Documentation ¶
Index ¶
- type Cache
- func (c *Cache) GetCertificatePath() string
- func (c *Cache) GetPrivateKeyPath() string
- func (c *Cache) GetRootCertificate() (*x509.Certificate, error)
- func (c *Cache) GetRootCertificatePath() string
- func (c *Cache) GetTlsCertificate() (*tls.Certificate, error)
- func (c *Cache) SetDir(dir string) error
- func (c *Cache) Valid(client *Client) bool
- type Client
- func (c *Client) DownloadRootCertificate(cache *Cache) error
- func (c *Client) GetCertificateFunc(chi *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (c *Client) Request(cache *Cache, cr *SimpleRequest) error
- func (c *Client) RequestForDomains(cache *Cache, domains []string, days int) error
- func (c *Client) RequestForEmails(cache *Cache, emails []string, days int) error
- func (c *Client) RequestForIps(cache *Cache, ips []string, days int) error
- func (c *Client) RequestWithCSR(cache *Cache, csr *x509.CertificateRequest) error
- func (c *Client) SetupWithCSR(cache *Cache, csr *x509.CertificateRequest)
- func (c *Client) SetupWithSimpleRequest(cache *Cache, sr *SimpleRequest)
- type ClientSettings
- type ErrStillValid
- type SimpleRequest
- type SimpleRequestSubject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { CacheDir string PrivateKeyFilename string CertificateFilename string RootCertificateFilename string }
Cache represents local directory and file paths for certificates and private keys
func NewCache ¶
NewCache returns a *Cache with default values: CacheDir is .certs, CertificateFilename is cert.pem, PrivateKeyFilename is key.pem
func (*Cache) GetCertificatePath ¶
GetCertificatePath returns the full path the Cache's certificate file
func (*Cache) GetPrivateKeyPath ¶
GetPrivateKeyPath returns the full path the Cache's private key file
func (*Cache) GetRootCertificate ¶
func (c *Cache) GetRootCertificate() (*x509.Certificate, error)
func (*Cache) GetRootCertificatePath ¶
GetRootCertificatePath returns the full path the Cache's root certificate file Usually there is no need to touch that at all
func (*Cache) GetTlsCertificate ¶
func (c *Cache) GetTlsCertificate() (*tls.Certificate, error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the structure required to obtain certificates (and private keys) from a remote location.
func NewClient ¶
func NewClient(baseUrl, token string, settings *ClientSettings) *Client
NewClient returns a *Client with a new *http.Client and baseUrl and token fields set to their parameter values
func (*Client) DownloadRootCertificate ¶
func (*Client) GetCertificateFunc ¶
func (c *Client) GetCertificateFunc(chi *tls.ClientHelloInfo) (*tls.Certificate, error)
func (*Client) Request ¶
func (c *Client) Request(cache *Cache, cr *SimpleRequest) error
Request requests a fresh certificate and private key with the metadata contained in the *SimpleRequest and puts it into *Cache.
func (*Client) RequestForDomains ¶
RequestForDomains is a convenience method to fetch a certificate and a private key for just the selected domain(s) without a care about other settings.
func (*Client) RequestForEmails ¶
RequestForEmails is a convenience method to fetch a certificate and a private key for just the selected email address(es) without a care about other settings.
func (*Client) RequestForIps ¶
RequestForIps is a convenience method to fetch a certificate and a private key for just the selected IP address(es) without a care about other settings.
func (*Client) RequestWithCSR ¶
func (c *Client) RequestWithCSR(cache *Cache, csr *x509.CertificateRequest) error
RequestWithCSR is like Request but with the subtle difference that it takes a x509.CertificateRequest, which is commonly known as a Certificate Signing Request (CSR). The *Cache must have the PrivateKeyFilename field set to a file containing a valid private key. Otherwise the process will fail.
func (*Client) SetupWithCSR ¶
func (c *Client) SetupWithCSR(cache *Cache, csr *x509.CertificateRequest)
SetupWithCSR is a preparatory call in order to use GetCertificateFunc with an http.Server struct
func (*Client) SetupWithSimpleRequest ¶
func (c *Client) SetupWithSimpleRequest(cache *Cache, sr *SimpleRequest)
SetupWithSimpleRequest is a preparatory call in order to use GetCertificateFunc with an http.Server struct
type ClientSettings ¶
type ClientSettings struct { Transport *http.Transport ClientTimeout time.Duration StrictMode bool ChallengePort uint16 }
ClientSettings represent meta data useful for altering the behaviour of a *Client
type ErrStillValid ¶
type ErrStillValid struct{}
func (ErrStillValid) Error ¶
func (e ErrStillValid) Error() string
type SimpleRequest ¶
type SimpleRequest struct { Domains []string `json:"domains"` IPs []string `json:"ips"` EmailAddresses []string `json:"emails"` Subject SimpleRequestSubject `json:"subject,omitempty"` Days int `json:"days"` }
SimpleRequest defines a request for a new certificate and private key. The field Subject is optional and can be omitted. Days can be between 1 and 182. If the value is higher than 182, then it will be set to 182 on the server side. If it is lower than 1, it will be set to 1 on the server side.
You can either supply zero or more Domains, zero or more IPs and zero or more EmailAddresses.
type SimpleRequestSubject ¶
type SimpleRequestSubject struct { Organization string `json:"organization"` Country string `json:"country"` Province string `json:"province"` Locality string `json:"locality"` StreetAddress string `json:"street_address"` PostalCode string `json:"postal_code"` }
SimpleRequestSubject represents the subject of a SimpleRequest