Browse Source

Remove explicit references to specific draft acme versions

master
Isaac 3 years ago
parent
commit
92b030658c
  1. 2
      README.md
  2. 4
      account.go
  3. 2
      acme.go
  4. 2
      authorization.go
  5. 2
      certificate.go
  6. 2
      challenge.go
  7. 3
      order.go
  8. 1
      problem.go
  9. 9
      types.go

2
README.md

@ -4,7 +4,7 @@
## About
`eggsampler/acme` is a Go client library implementation for [ACME v2 revision 10](https://tools.ietf.org/html/draft-ietf-acme-acme-10), specifically for use with the [Let's Encrypt](https://letsencrypt.org/) service.
`eggsampler/acme` is a Go client library implementation for [ACME](https://datatracker.ietf.org/doc/draft-ietf-acme-acme/), specifically for use with the [Let's Encrypt](https://letsencrypt.org/) service.
The library is designed to provide a wrapper over exposed directory endpoints and provide objects in easy to use structures.

4
account.go

@ -10,7 +10,6 @@ import (
)
// NewAccount registers a new account with the acme service
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.3
func (c Client) NewAccount(privateKey crypto.Signer, onlyReturnExisting, termsOfServiceAgreed bool, contact ...string) (Account, error) {
newAccountReq := struct {
OnlyReturnExisting bool `json:"onlyReturnExisting"`
@ -50,7 +49,6 @@ func (c Client) NewAccount(privateKey crypto.Signer, onlyReturnExisting, termsOf
}
// UpdateAccount updates an existing account with the acme service.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.3.2
func (c Client) UpdateAccount(account Account, termsOfServiceAgreed bool, contact ...string) (Account, error) {
updateAccountReq := struct {
TermsOfServiceAgreed bool `json:"termsOfServiceAgreed"`
@ -76,7 +74,6 @@ func (c Client) UpdateAccount(account Account, termsOfServiceAgreed bool, contac
}
// AccountKeyChange rolls over an account to a new key.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.3.6
func (c Client) AccountKeyChange(account Account, newPrivateKey crypto.Signer) (Account, error) {
if c.dir.KeyChange == "" {
return account, ErrUnsupported
@ -110,7 +107,6 @@ func (c Client) AccountKeyChange(account Account, newPrivateKey crypto.Signer) (
}
// DeactivateAccount deactivates a given account.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.3.7
func (c Client) DeactivateAccount(account Account) (Account, error) {
deactivateReq := struct {
Status string `json:"status"`

2
acme.go

@ -27,7 +27,6 @@ const (
)
// NewClient creates a new acme client given a valid directory url.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.1.1
func NewClient(directoryURL string, options ...OptionFunc) (Client, error) {
httpClient := http.DefaultClient
@ -77,7 +76,6 @@ func (c Client) getPollingDurations() (time.Duration, time.Duration) {
// Helper function to have a central point for performing http requests.
// Stores any returned nonces in the stack.
func (c Client) do(req *http.Request, addNonce bool) (*http.Response, error) {
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-6.1
// identifier for this client, as well as the default go user agent
if c.userAgentSuffix != "" {
req.Header.Set("User-Agent", userAgentString+" "+c.userAgentSuffix)

2
authorization.go

@ -3,7 +3,6 @@ package acme
import "net/http"
// FetchAuthorization fetches an authorization from an authorization url provided in an order.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.5
func (c Client) FetchAuthorization(account Account, authURL string) (Authorization, error) {
authResp := Authorization{}
_, err := c.post(authURL, account.URL, account.PrivateKey, "", &authResp, http.StatusOK)
@ -30,7 +29,6 @@ func (c Client) FetchAuthorization(account Account, authURL string) (Authorizati
}
// DeactivateAuthorization deactivate a provided authorization url from an order.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.5.2
func (c Client) DeactivateAuthorization(account Account, authURL string) (Authorization, error) {
deactivateReq := struct {
Status string `json:"status"`

2
certificate.go

@ -10,7 +10,6 @@ import (
)
// FetchCertificates downloads a certificate chain from a url given in an order certificate.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.4.2
func (c Client) FetchCertificates(certificateURL string) ([]*x509.Certificate, error) {
resp, raw, err := c.getRaw(certificateURL, http.StatusOK)
if err != nil {
@ -46,7 +45,6 @@ func (c Client) FetchCertificates(certificateURL string) ([]*x509.Certificate, e
}
// RevokeCertificate revokes a given certificate given the certificate key or account key, and a reason.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.6
func (c Client) RevokeCertificate(account Account, cert *x509.Certificate, key crypto.Signer, reason int) error {
revokeReq := struct {
Certificate string `json:"certificate"`

2
challenge.go

@ -10,7 +10,6 @@ import (
)
// EncodeDNS01KeyAuthorization encodes a key authorization and provides a value to be put in the TXT record for the _acme-challenge DNS entry.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-8.4
func EncodeDNS01KeyAuthorization(keyAuth string) string {
h := sha256.Sum256([]byte(keyAuth))
return base64.RawURLEncoding.EncodeToString(h[:])
@ -47,7 +46,6 @@ func checkUpdatedChallengeStatus(challenge Challenge) (bool, error) {
}
// UpdateChallenge responds to a challenge to indicate to the server to complete the challenge.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.5.1
func (c Client) UpdateChallenge(account Account, challenge Challenge) (Challenge, error) {
resp, err := c.post(challenge.URL, account.URL, account.PrivateKey, struct{}{}, &challenge, http.StatusOK)
if err != nil {

3
order.go

@ -15,7 +15,6 @@ import (
)
// NewOrder initiates a new order for a new certificate.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.4
func (c Client) NewOrder(account Account, identifiers []Identifier) (Order, error) {
newOrderReq := struct {
Identifiers []Identifier `json:"identifiers"`
@ -59,7 +58,6 @@ func (c Client) FetchOrder(account Account, orderURL string) (Order, error) {
}
// Helper function to determine whether an order is "finished" by it's status.
// More info: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.4
func checkFinalizedOrderStatus(order Order) (bool, error) {
switch order.Status {
case "invalid":
@ -101,7 +99,6 @@ func checkFinalizedOrderStatus(order Order) (bool, error) {
// FinalizeOrder indicates to the acme server that the client considers an order complete and "finalizes" it.
// If the server believes the authorizations have been filled successfully, a certificate should then be available.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.4
// This function assumes that the order status is "ready".
func (c Client) FinalizeOrder(account Account, order Order, csr *x509.CertificateRequest) (Order, error) {
finaliseReq := struct {

1
problem.go

@ -8,7 +8,6 @@ import (
)
// Problem represents an error returned by an acme server.
// More details: https://tools.ietf.org/html/rfc7807
type Problem struct {
Status int `json:"status"`

9
types.go

@ -16,7 +16,6 @@ const (
)
// Constants used for certificate revocation, used for RevokeCertificate
// More details: https://tools.ietf.org/html/rfc5280#section-5.3.1
const (
ReasonUnspecified = iota // 0
ReasonKeyCompromise // 1
@ -36,7 +35,6 @@ var (
)
// Directory object as returned from the client's directory url upon creation of client.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.1.1
type Directory struct {
NewNonce string `json:"newNonce"` // url to new nonce endpoint
NewAccount string `json:"newAccount"` // url to new account endpoint
@ -46,7 +44,6 @@ type Directory struct {
KeyChange string `json:"keyChange"` // url to key change endpoint
// meta object containing directory metadata
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-9.7.6
Meta struct {
TermsOfService string `json:"termsOfService"`
Website string `json:"website"`
@ -78,7 +75,6 @@ type Client struct {
}
// Account structure representing fields in an account object.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.1.2
type Account struct {
Status string `json:"status"`
Contact []string `json:"contact"`
@ -98,14 +94,12 @@ type Account struct {
}
// Identifier object used in order and authorization objects
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.1.3
type Identifier struct {
Type string `json:"type"`
Value string `json:"value"`
}
// Order object returned when fetching or creating a new order.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.1.3
type Order struct {
Status string `json:"status"`
Expires time.Time `json:"expires"`
@ -121,7 +115,6 @@ type Order struct {
}
// Authorization object returned when fetching an authorization in an order.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.1.4
type Authorization struct {
Identifier Identifier `json:"identifier"`
Status string `json:"status"`
@ -137,7 +130,6 @@ type Authorization struct {
}
// Challenge object fetched in an authorization or directly from the challenge url.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-8
type Challenge struct {
Type string `json:"type"`
URL string `json:"url"`
@ -154,7 +146,6 @@ type Challenge struct {
}
// OrderList of challenge objects.
// More details: https://tools.ietf.org/html/draft-ietf-acme-acme-10#section-7.1.2.1
type OrderList struct {
Orders []string `json:"orders"`

Loading…
Cancel
Save