27 Commits
Author SHA1 Message Date
Daniel McCarney b4dcfb54b8 acme: support standards-compliant order finalization
When an order finalization response is not immediately valid,
Client.CreateOrderCert depends on the ACME server returning a Location
header. The header value is used as the URL for polling the updated
order status. RFC 8555 does not require this header, so CreateOrderCert
does not interoperate with ACME servers that omit it (e.g. Pebble
v2.9.0+).

This commit adds Client.CreateCertFromOrder, which accepts an *Order and
uses its URI for polling instead of relying on the finalization
response's Location header. It also updates existing callers and
documentation to use the new method and updates the integration tests to
Pebble v2.10.1 (the latest available version), which omits the
finalization Location header.

Fixes golang/go#77704

Change-Id: I0852f19c5d18d6debc9c9686fa2c14a2e39663c2
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/817000
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2026-09-18 12:05:15 -07:00
Russ Cox 7b82a4e95d all: gofmt
Gofmt to update doc comments to the new formatting.

For golang/go#51082.

Change-Id: I076031b6613691eefbb0f21739366e3fd2011ec9
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/399356
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-11 22:02:26 +00:00
Ben BurkertandBrad Fitzpatrick 65fa2f7aa8 acme: remove support for pre-RFC 8555 ACME spec
LetsEncrypt removed it anyway.

No API changes. Just a lot of deleted code.

Fixes golang/go#46654

Co-authored-by: Brad Fitzpatrick <bradfitz@golang.org>
Change-Id: I65cd0d33236033682b767403ad92aa572bee4fdd
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/380314
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2022-02-09 15:49:31 +00:00
Lars Lehtonen 0a56756db3 acme/internal/acmeprobe: fix dropped error variable
This fixes a dropped err in runPreauthz().

Change-Id: I46f98d0a21e037a49e4b779895214538d1162376
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/206237
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-11-08 22:47:45 +00:00
Alex Vaghin f9e2070545 acme/internal: add a prober program
While working on the RFC 8555 implementation for golang/go#21081,
I've been also manually verifying the functionality against
various CAs both draft-02 and RFC versions.

This does not of course replace automated tests
yet it might be useful to others.

It is not a _test.go file because the program may require
interactive user input for dns-01 challenge types and needs
to flush logs to stderr during its run.

Change-Id: Ia324b08b30308441cc0705648e30c0112b0fa0c8
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/194681
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-01 17:07:39 +00:00
Alex Vaghin d3c1194e7c acme: expose internal/acme as acme package
This moves all of internal/acme into the acme package,
making the lower level API accessible by any other package.

Fixes golang/go#16938.

Change-Id: Ie35f4b6b6b42ebb7fb4ad03ba067df8c3063feff
Reviewed-on: https://go-review.googlesource.com/28297
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Alex Vaghin <ddos@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-31 19:38:21 +00:00
Alex Vaghin b13fc1fd38 acme: take a user provided key in TLSSNIxChallengeCert
Some systems can only operate with a certain key type, for instance RSA,
which makes it impossible for them to use Client provided certificates
to fulfill tls-sni-x challenges since TLSSNIxChallengeCert methods
of the Client always generate ECDSA-based certificates.

At the same time we want to keep using ECDSA-based certificates
in autocert.Manager.

This change allows for a user supplied key when generating tls-sni-x
challenge certficates.

Change-Id: I04f617ff99794a71ef23ad259cb333839f13ae1c
Reviewed-on: https://go-review.googlesource.com/27750
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-30 15:40:08 +00:00
Alex Vaghin 351dc6a5bf acme: add client.DNS01ChallengeRecord
This change adds implementation for dns-01 challenge responses.

Change-Id: I22b2b304ca4a2caeec2980feff19a6c2bc277d8c
Reviewed-on: https://go-review.googlesource.com/27613
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-24 17:30:33 +00:00
Alex Vaghin b35ccbc95a acme: add Client.WaitAuthorization for polling
It is quite often the case users need to poll an authorization until it
reaches a final state.

This change adds a handy method to do exactly that,
as well as updating autocert.Manager to use the new method.

Change-Id: I4d25e4ee751731815b77980caab6da98d3440b5d
Reviewed-on: https://go-review.googlesource.com/27431
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 20:33:07 +00:00
Alex Vaghin 1ba5ec0bf2 acme: add StatusValid to expected values for Authorize
Let's Encrypt may respond with the "valid" value in status
field to authorization requests:
https://github.com/letsencrypt/boulder/blob/0543691d9e2cbcc1b94baf3b9fab4e64ca2750ef/ra/ra.go#L373-L402

The spec isn't clear on this:
https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.4

Either way, this change follows common sense and should not produce
unexpected results.

Change-Id: Iac55aa1fb17d458f6d62e8da875ed86e3e4afbc3
Reviewed-on: https://go-review.googlesource.com/27432
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 17:42:09 +00:00
Alex Vaghin 7e016f1856 acme: use EC keys where possible
This change improves tests speed further by switching to EC keys where
possible.

We are also switching to EC-based token certs for TLS-SNI-x challenges
in this change. I've confirmed it works with Let's Encrypt production
servers as well, by fulfilling TLS-SNI-01 challenge for a test domain
using autocert.Manager.

Change-Id: I07c532d535ba413af97463dd97cca3d650dfccee
Reviewed-on: https://go-review.googlesource.com/27439
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 17:01:11 +00:00
Alex Vaghin 3461a682e1 acme: add support for ECDSA-based signatures
A previous change, https://go-review.googlesource.com/25462, added
support only for encoding JWK with a public ECDSA key.
Client users weren't actually able to make any request
using a EC key because of invalid JWS header and signature.

This change adds EC-based header and signature, which makes the Client
to have full support for ECDSA keys now.

Change-Id: Ia88f08465ce941f72d2001019f5aa47441a17d6e
Reviewed-on: https://go-review.googlesource.com/27438
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 15:57:48 +00:00
Alex Vaghin 9fbab14f90 acme: add Client.RevokeCert for certificate revocation
This change adds RevokeCert method to Client, implemented as described
in https://tools.ietf.org/html/draft-ietf-acme-acme-02#section-6.6
and https://tools.ietf.org/html/draft-ietf-acme-acme-03#section-6.5.

Change-Id: Ib0defbc299b46268c0f36dbe0f29f0081a3598d5
Reviewed-on: https://go-review.googlesource.com/27092
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 14:31:42 +00:00
Alex Vaghin 1f83de14df acme: improve http-01 challenge API
This makes http-01 handling more consistent with tls-sni-* methods
and, hopefully, future implementation such as dns-01 and oob-01.

Change-Id: If1a4a47ee8528ef19960fee4e6860392c1813fe6
Reviewed-on: https://go-review.googlesource.com/27011
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 19:51:47 +00:00
Alex Vaghin 807ffeae6d acme: context-aware Client methods
This change adds a context to all exported methods of Client
which may perform network requests, to allow for easier control
over request timeouts and cancellation.

Change-Id: I635a4d7ad39a63ed9e6823b1af12fbb201c19647
Reviewed-on: https://go-review.googlesource.com/27091
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-16 16:58:05 +00:00
Alex Vaghin 6575f7ea32 acme: build up full chain certs when requested
The latest ACME spec (v3) changed the wording to:

    ... the server MUST send one or more link relation header
    fields [RFC5988] with relation "up", each indicating a single
    certificate resource for the issuer of this certificate.  The server
    MAY also include the "up" links from these resources to enable the
    client to build a full certificate chain.

See https://tools.ietf.org/html/draft-ietf-acme-acme-03#section-6.3.1.

Before this change, Client was fetching only the first "up" link, but never
checked to follow the chain further. To my knowledge, Let's Encrypt never
provided a chain longer than 1, this is just to make the Client future proof.

Also fixes google/acme#26.

Change-Id: I35cf5f1997b21a0b2a2d0a732043a7e04b7f1c45
Reviewed-on: https://go-review.googlesource.com/26693
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-15 19:30:22 +00:00
Alex Vaghin a548aac93e acme: format Client and errors
- move required fields before optional in the Client struct
- prefix all errors with "acme: "
- rename tos to tosURL (Terms of Service)

Change-Id: I6914b7e75d1e0559ff8303d390238c2a27145c8e
Reviewed-on: https://go-review.googlesource.com/27010
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-13 21:12:40 +00:00
Alex Vaghin 6c932297e1 acme: preserve account URI on get and update
Let's Encrypt has always provided Account URI in a response
to any registration request (new, get and update) in the Location
header, up until recently (?).

Today, LE's servers provide Account URI only for new-reg requests.
In fact, the spec does not say anything about Account URI and Location
header for "get" and "update" requests.

This change preserves Account URI in return values for "get" and "update"
requests, which is already provided by the caller anyway.

Change-Id: I8b1112d7443935715e9184a511b5e30a27008e8c
Reviewed-on: https://go-review.googlesource.com/26931
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-12 21:42:43 +00:00
Alex Vaghin 595bbbd7f5 acme: improve TLSSNI{01,02}ChallengeCert methods
This is a split of https://go-review.googlesource.com/23970 (patch set 8)
to address only Client changes:

1. Expose expected server name value of TLS SNI ClientHello message
2. Fix a bug where returned error value was nil.

Change-Id: I21f571652e9bbef80a2222dc34fce767270b7c48
Reviewed-on: https://go-review.googlesource.com/26852
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-11 15:23:48 +00:00
Alex Vaghin 5f961cd492 acme: simplify TLS-SNI challenge cert
There's no need to PEM-encode key/cert pair to create a tls.Certificate.

All tls.X509KeyPair does is decode back to DER and verify that the
key corresponds to the cert. But we already know it does.

Change-Id: Icccdaf7fd86317147476fb03cbc71ee7b4a06edb
Reviewed-on: https://go-review.googlesource.com/26694
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-10 14:59:58 +00:00
Anmol Sethi e0d166c33c acme: support for ECDSA keys
Change-Id: I4956b8277969718e70bb4f5f9893213b58e159fc
Reviewed-on: https://go-review.googlesource.com/25462
Reviewed-by: Alex Vaghin <ddos@google.com>
2016-08-05 15:12:09 +00:00
Alex Vaghin 7a1054f3ac acme: TLS-SNI challenges implementation
Current and N-1 versions of the spec adopted TLS-SNI-02, but Let's
Encrypt seems to support TLS-SNI-01, devised in v1 of the spec.

This change implements both, older 01 and current 02 versions of TLS-SNI
challenges.

Change-Id: I2bb76ad852e105098f703cb6113d3996c0e0b118
Reviewed-on: https://go-review.googlesource.com/25450
Reviewed-by: Alex Vaghin <ddos@google.com>
2016-08-04 08:26:12 +00:00
Alex Vaghin 611beeb3d5 acme: specify which version exactly is implemented
The WG has recently published v3 of the spec.
The package implementation is still at v2. So is Let's Encrypt, to be
honest.

Regardless, I think it makes sense to point to the exact version
the package is compatible with.

Change-Id: Ibb3fc51aae363d72f67f7e876ef46c4f51c8da0b
Reviewed-on: https://go-review.googlesource.com/25451
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-03 21:26:26 +00:00
Alex Vaghin 1da79bda50 acme: prompt for terms agreement
Allow Client.Register callers to report CA terms agreement,
simplifying the registration usage.

Change-Id: Ia2c237f31c8375b5ae669bbd07d9294c329f59b8
Reviewed-on: https://go-review.googlesource.com/23973
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-14 16:03:19 +00:00
Alex Vaghin c2f4947f41 acme: default values and discovery
Add Directory to the Client fields. This removes ACME resource URL
argument from almost all of the Client methods and makes it easier to
use.

Change-Id: I245c975fda914d50fe62ebbec55a4fcf34cb57f2
Reviewed-on: https://go-review.googlesource.com/23972
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-09 14:46:51 +00:00
Alex Vaghin 47ff8dfbc5 acme: format test data
A test RSA private key was missing "-" in the END delimiter.
While working fine with encoding/pem, other tools like openssl
seem to have more strict requirements.

See
https://github.com/golang/crypto/commit/1777f3ba8c1fed80fcaec3317e3aaa4f627764d2#commitcomment-17343818
for more details.

Change-Id: I5153bb9cf405755d6621f69c1329da8290695eed
Reviewed-on: https://go-review.googlesource.com/22871
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-06 18:11:22 +00:00
Alex Vaghin 1777f3ba8c acme: initial import of ACME implementation
Originated from github.com/google/goacme.

This does not include goacme command line program
github.com/google/goacme/cmd/goacme. It will probably live somewhere
else.

Change-Id: I852d55c1a3673fab208e6e2aa19d22be42b8719f
Reviewed-on: https://go-review.googlesource.com/20837
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-13 17:25:35 +00:00