Documentation ¶
Overview ¶
Package letsencrypt implements an ACME client.
Index ¶
- Constants
- type Authorization
- type CertificateResponse
- type Challenge
- func (chal Challenge) DNS(accountKey interface{}) (subdomain, txt string, err error)
- func (chal Challenge) HTTP(accountKey interface{}) (urlPath, resource string, err error)
- func (chal Challenge) ProofOfPossession(accountKey, certKey interface{}) (Challenge, error)
- func (chal Challenge) TLSSNI(accountKey interface{}) (map[string]*tls.Certificate, error)
- type Client
- func (c *Client) Authorization(authURI string) (Authorization, error)
- func (c *Client) Bundle(certResp *CertificateResponse) (bundledPEM []byte, err error)
- func (c *Client) Challenge(chalURI string) (Challenge, error)
- func (c *Client) ChallengeReady(accountKey interface{}, chal Challenge) error
- func (c *Client) NewAuthorization(accountKey interface{}, typ, val string) (auth Authorization, authURL string, err error)
- func (c *Client) NewCertificate(accountKey interface{}, csr *x509.CertificateRequest) (*CertificateResponse, error)
- func (c *Client) NewRegistration(accountKey interface{}) (reg Registration, err error)
- func (c *Client) RenewCertificate(certURI string) (*CertificateResponse, error)
- func (c *Client) Retry(certResp *CertificateResponse) error
- func (c *Client) RevokeCertificate(accountKey interface{}, pemBytes []byte) error
- func (c *Client) Terms() string
- func (c *Client) UpdateRegistration(accountKey interface{}, reg Registration) (Registration, error)
- type Error
- type JWSValidation
- type Registration
Constants ¶
const ( ChallengeDNS = "dns-01" ChallengeHTTP = "http-01" ChallengeTLSSNI = "tls-sni-01" )
const ( StatusPending = "pending" StatusInvalid = "invalid" StatusValid = "valid" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorization ¶
type Authorization struct { Identifier struct { Type string `json:"type"` Value string `json:"value"` } `json:"identifier"` Status string `json:"status,omitempty"` Expires time.Time `json:"expires,omitempty"` Challenges []Challenge `json:"challenges,omitempty"` Combs [][]int `json:"combinations,omitempty"` }
Authorization represents a set of challenges issued by the server for the given identifier.
func (Authorization) Combinations ¶
func (a Authorization) Combinations(supportedChallenges ...string) [][]Challenge
Combinations returns the set of challenges which the client supports. Completing one of these sets is enough to prove ownership of an identifier.
type CertificateResponse ¶
type CertificateResponse struct { Certificate *x509.Certificate RetryAfter int URI string StableURI string Issuer string }
CertificateResponse holds response items after requesting a Certificate.
func (*CertificateResponse) IsAvailable ¶
func (c *CertificateResponse) IsAvailable() bool
IsAvailable returns bool true if CertificateResponse has a certificate available. It's a convenience function, but it helps with readability.
type Challenge ¶
type Challenge struct { ID int64 `json:"id,omitempty"` Type string `json:"type"` URI string `json:"uri"` Status string `json:"status,omitempty"` Validated time.Time `json:"validated,omitempty"` Error *Error `json:"error,omitempty"` // Data used by various challenges Token string `json:"token,omitempty"` KeyAuthorization string `json:"keyAuthorization,omitempty"` N int `json:"n,omitempty"` Certs []string `json:"certs,omitempty"` AccountKey *jose.JsonWebKey `json:"accountKey,omitempty"` Authorization *JWSValidation `json:"authorization,omitempty"` }
Challenge represents a server challenge for a given domain name.
func (Challenge) DNS ¶
DNS returns the subdomain name and the TXT value you need to set for that subdomain. The ACME server will make DNS TXT lookup on that subdomain and verify that the value matches. Keep in mind that DNS TTL's might prevent the lookup from working correctly the first few times and ChallengeReady will continue to loop if the record is missing/invalid. It is recommended that you set the record to the lowest TTL allowed by your provider.
func (Challenge) HTTP ¶
HTTP returns a URL path and HTTP response body that the ACME server will check when verifying the challenge.
func (Challenge) ProofOfPossession ¶
Not yet implemented
func (Challenge) TLSSNI ¶
func (chal Challenge) TLSSNI(accountKey interface{}) (map[string]*tls.Certificate, error)
TLSSNI returns TLS certificates for a set of server names. The ACME server will make a TLS Server Name Indication handshake with the given domain. The domain must present the returned certifiate for each name.
type Client ¶
type Client struct { // PollInterval determines how quickly the client will // request updates on a challenge from the ACME server. // If unspecified, it defaults to 500 milliseconds. PollInterval time.Duration // Amount of time after the client notifies the server a challenge is // ready, and when it will stop checking for updates. // If unspecified, it defaults to 30 seconds. PollTimeout time.Duration // contains filtered or unexported fields }
Client is a client for a single ACME server.
func NewClient ¶
NewClient creates a client of a ACME server by querying the server's resource directory and attempting to resolve the URL of the terms of service.
func NewClientWithTransport ¶
func NewClientWithTransport(directoryURL string, t http.RoundTripper) (*Client, error)
NewClientWithTransport creates a client of a ACME server by querying the server's resource directory and attempting to resolve the URL of the terms of service.
func (*Client) Authorization ¶
func (c *Client) Authorization(authURI string) (Authorization, error)
Authorization returns the authorization object associated with the given authorization URI.
func (*Client) Bundle ¶
func (c *Client) Bundle(certResp *CertificateResponse) (bundledPEM []byte, err error)
Bundle bundles the certificate with the issuer certificate.
func (*Client) Challenge ¶
Challenge returns the challenge object associated with the given challenge URI.
func (*Client) ChallengeReady ¶
ChallengeReady informs the server that the provided challenge is ready for verification.
The client then begins polling the server for confirmation on the result of the status.
func (*Client) NewAuthorization ¶
func (c *Client) NewAuthorization(accountKey interface{}, typ, val string) (auth Authorization, authURL string, err error)
NewAuthorization requests a set of challenges from the server to prove ownership of a given resource. Only known type is 'dns'.
NOTE: Currently the only way to recover an authorization object is with the returned authorization URL.
func (*Client) NewCertificate ¶
func (c *Client) NewCertificate(accountKey interface{}, csr *x509.CertificateRequest) (*CertificateResponse, error)
NewCertificate requests a certificate from the ACME server.
csr must have already been signed by a private key.
func (*Client) NewRegistration ¶
func (c *Client) NewRegistration(accountKey interface{}) (reg Registration, err error)
NewRegistration registers a key pair with the ACME server. If the key pair is already registered, the registration object is recovered.
func (*Client) RenewCertificate ¶
func (c *Client) RenewCertificate(certURI string) (*CertificateResponse, error)
RenewCertificate attempts to renew an existing certificate. Let's Encrypt may return the same certificate. You should load your current x509.Certificate and use the Equal method to compare to the "new" certificate. If it's identical, you'll need to run NewCertificate and/or start a new certificate flow.
func (*Client) Retry ¶
func (c *Client) Retry(certResp *CertificateResponse) error
Retry request retries the certificate if it was unavailable when calling NewCertificate or RenewCertificate.
Note: If you are renewing a certificate, LetsEncrypt may return the same certificate. You should load your current x509.Certificate and use the Equal method to compare to the "new" certificate. If it's identical, you'll need to request a new certificate using NewCertificate, or if your chalenges have expired, start a new certificate flow entirely.
func (*Client) RevokeCertificate ¶
RevokeCertificate takes a PEM encoded certificate or bundle and attempts to revoke it.
func (*Client) Terms ¶
Terms returns the URL of the server's terms of service. All accounts registered using this client automatically accept these terms.
func (*Client) UpdateRegistration ¶
func (c *Client) UpdateRegistration(accountKey interface{}, reg Registration) (Registration, error)
UpdateRegistration sends the updated registration object to the server.
type Error ¶
type Error struct { Typ string `json:"type"` Status int `json:"status"` Detail string `json:"detail"` }
A HTTP error generated by the ACME server.
type JWSValidation ¶
type Registration ¶
type Registration struct { PublicKey *jose.JsonWebKey `json:"key,omitempty"` Contact []string `json:"contact,omitempty"` Agreement string `json:"agreement,omitempty"` Authorizations string `json:"authorizations,omitempty"` Certificates string `json:"certificates,omitempty"` Id int `json:"id,omitempty"` InitialIp string `json:"initialIp,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` Resource string `json:"resource,omitempty"` }
Registration holds account information for a given key pair.