Commit Graph

260 Commits

Author SHA1 Message Date
Aaron Gable 305ef9cce9
Improve error checking paradigm (#5920)
We have decided that we don't like the if err := call(); err != nil
syntax, because it creates confusing scopes, but we have not cleaned up
all existing instances of that syntax. However, we have now found a
case where that syntax enables a bug: It caused readers to believe that
a later err = call() statement was assigning to an already-declared err
in the local scope, when in fact it was assigning to an
already-declared err in the parent scope of a closure. This caused our
ineffassign and staticcheck linters to be unable to analyze the
lifetime of the err variable, and so they did not complain when we
never checked the actual value of that error.

This change standardizes on the two-line error checking syntax
everywhere, so that we can more easily ensure that our linters are
correctly analyzing all error assignments.
2022-02-01 14:42:43 -07:00
Aaron Gable ab79f96d7b
Fixup staticcheck and stylecheck, and violations thereof (#5897)
Add `stylecheck` to our list of lints, since it got separated out from
`staticcheck`. Fix the way we configure both to be clearer and not
rely on regexes.

Additionally fix a number of easy-to-change `staticcheck` and
`stylecheck` violations, allowing us to reduce our number of ignored
checks.

Part of #5681
2022-01-20 16:22:30 -08:00
Aaron Gable 11263893eb
Remove RA NewAuthorization and NewCertificate (#5900)
These gRPC methods were only used by the ACMEv1 code paths.
Now that boulder-wfe has been fully removed, we can be confident
that no clients ever call these methods, and can remove them from
the gRPC service interface.

Part of #5816
2022-01-20 14:47:21 -08:00
Jacob Hoffman-Andrews 1c573d592b
Add account cache to WFE (#5855)
Followup from #5839.

I chose groupcache/lru as our LRU cache implementation because it's part
of the golang org, written by one of the Go authors, and very simple
and easy to read.

This adds an `AccountGetter` interface that is implemented by both the
AccountCache and the SA. If the WFE config includes an AccountCache field,
it will wrap the SA in an AccountCache with the configured max size and
expiration time.

We set an expiration time on account cache entries because we want a
bounded amount of time that they may be stale by. This will be used in
conjunction with a delay on account-updating pathways to ensure we don't
allow authentication with a deactivated account or changed key.

The account cache stores corepb.Registration objects because protobufs
have an established way to do a deep copy. Deep copies are important so
the cache can maintain its own internal state and ensure nothing external
is modifying it.

As part of this process I changed construction of the WFE. Previously,
"SA" and "RA" were public fields that were mutated after construction. Now
they are parameters to the constructor, along with the new "accountGetter"
parameter.

The cache includes stats for requests categorized by hits and misses.
2021-12-15 11:10:23 -08:00
Aaron Gable a70d994ff1
ARI: Set Retry-After header to 6 hours (#5766)
The draft requires that the renewalInfo endpoint have a
Retry-After header indicating how often clients should poll
for their renewal information. As per our previous thinking,
set this timer to 6 hours for now.

Fixes #5765
2021-11-05 11:38:45 -07:00
Aaron Gable 1a1cd24237
Add tests for the experimental `renewalInfo` endpoint (#5750)
Add a unit test and an integration test that both exercise the new
experimental ACME Renewal Info endpoint. These tests do not
yet validate the contents of the response, just that the appropriate
HTTP response code is returned, but they will be developed as the
code under test evolves.

Fixes #5674
2021-10-27 15:00:56 -07:00
Aaron Gable eb5d0e9ba9
Update golangci-lint from v1.29.0 to v1.42.1 (#5745)
Update the version of golangci-lint we use in our docker image,
and update the version of the docker image we use in our tests.
Fix a couple places where we were violating lints (ineffective assign
and calling `t.Fatal` from outside the main test goroutine), and add
one lint (using math/rand) to the ignore list.

Fixes #5710
2021-10-22 16:26:59 -07:00
Andrew Gabbitas ba673673a4
Match revocation reason and request signing method (#5713)
Match revocation reason and request signing method

Add more detailed logging about request signing methods
2021-10-14 15:39:22 -06:00
Aaron Gable bab688b98f
Remove sa-wrappers.go (#5663)
Remove the last of the gRPC wrapper files. In order to do so:

- Remove the `core.StorageGetter` interface. Replace it with a new
  interface (whose methods include the `...grpc.CallOption` arg)
  inside the `sa/proto/` package.
- Remove the `core.StorageAdder` interface. There's no real use-case
  for having a write-only interface.
- Remove the `core.StorageAuthority` interface, as it is now redundant
  with the autogenerated `sapb.StorageAuthorityClient` interface.
- Replace the `certificateStorage` interface (which appears in two
  different places) with a single unified interface also in `sa/proto/`.
- Update all test mocks to include the `_ ...grpc.CallOption` arg in
  their method signatures so they match the gRPC client interface.
- Delete many methods from mocks which are no longer necessary (mostly
  because they're mocking old authz1 methods that no longer exist).
- Move the two `test/inmem/` wrappers into their own sub-packages to
  avoid an import cycle.
- Simplify the `satest` package to satisfy one of its TODOs and to
  avoid an import cycle.
- Add many methods to the `test/inmem/sa/` wrapper, to accommodate all
  of the methods which are called in unittests.

Fixes #5600
2021-09-27 13:25:41 -07:00
Samantha 8f4c105ad8
GRPC: Remove ra-wrappers.go (#5623)
- Remove `grpc/ra-wrapper.go`
- Remove `core.RegistrationAuthority` interface
- Add in-memory (`inmem`) wrappers for `RA` and `SA`
- Implement the minimum necessary methods for in-memory `RA` and `SA` wrappers

Fixes #5584
2021-09-03 12:34:38 -07:00
Aaron Gable 38dd2392d4
Unwrap sa.GetCertificateStatus (#5610)
Turn the `GetCertificateStatus` wrappers into pass-throughs.

Part of #5532
2021-08-30 16:35:34 -07:00
Aaron Gable f454892dd1
Unwrap SA Get[Pre]Certificate methods (#5588)
Make the gRPC wrappers for sa.GetCertificate and
sa.GetPrecertificate bare passthroughs. The latter of
these already took and returned appropriate protobufs,
so this change mostly just makes the former look like the
latter.

Part of #5532
2021-08-19 15:43:48 -07:00
Samantha 53b89707d5
GRPC: Unwrap ra.DeactivateAuthorization (#5567)
- Move `DeactivateAuthorization` logic from `grpc` to `ra` and `wfe`
- Update `ra` mocks in `wfe` tests
- Remove unnecessary marshalling between `core.Authorization` and
  `corepb.Authorization` in `ra` tests.

Fixes #5562
2021-08-12 11:30:57 -07:00
Aaron Gable b7ce627572
Remove SA Registration gRPC wrappers (#5551)
Remove all error checking and type transformation from the gRPC wrappers
for the following methods on the SA:
- GetRegistration
- GetRegistrationByKey
- NewRegistration
- UpdateRegistration
- DeactivateRegistration

Update callers of these methods to construct the appropriate protobuf
request messages directly, and to consume the protobuf response messages
directly. In many cases, this requires changing the way that clients
handle the `Jwk` field (from expecting a `JSONWebKey` to expecting a
slice of bytes) and the `Contacts` field (from expecting a possibly-nil
pointer to relying on the value of the `ContactsPresent` boolean field).

Implement two new methods in `sa/model.go` to convert directly between
database models and protobuf messages, rather than round-tripping
through `core` objects in between. Delete the older methods that
converted between database models and `core` objects, as they are no
longer necessary.

Update test mocks to have the correct signatures, and update tests to
not rely on `JSONWebKey` and instead use byte slices.

Fixes #5531
2021-08-04 13:33:41 -07:00
Samantha 2a5b9f651a
GRPC: Make ra.AdministrativelyRevokeCertificate a pass-through (#5558)
- Move `AdministrativelyRevokeCertificate` logic from `grpc` to `ra`
- Test new error conditions in `ra/ra_test.go`
- Update `ra` mocks in `wfe` tests

Fixes #5529
2021-08-02 13:52:00 -07:00
Andrew Gabbitas f599da27cc
Make ra.NewAuthorization wrapper passthrough (#5553)
Fixes: #5527
2021-08-02 13:09:59 -07:00
Andrew Gabbitas 1681c365aa
Make ra.NewCertificate a passthrough (#5557)
Fixes: #5528
2021-08-02 10:47:09 -07:00
Andrew Gabbitas 9133dba948
Make ra.DeactivateRegistration pass-through (#5522)
Fixes: #5521
2021-07-13 11:40:09 -06:00
Andrew Gabbitas 74909367cd
RA: Make NewOrder wrapper passthrough (#5486)
Fixes: #5436
2021-06-16 12:41:05 -06:00
Aaron Gable 8be32d3312
Use google.protobuf.Empty instead of core.Empty (#5454)
Replace `core.Empty` with `google.protobuf.Empty` in all of our gRPC
methods which consume or return an empty protobuf. The golang core
proto libraries provide an empty message type, so there is no need
for us to reinvent the wheel.

This change is backwards-compatible and does not require a special
deploy. The protobuf message descriptions of `core.Empty` and
`google.protobuf.Empty` are identical, so their wire-formats are
indistinguishable and therefore interoperable / cross-compatible.

Fixes #5443
2021-06-03 14:17:41 -07:00
Andrew Gabbitas b3d8337ca9
Log endpoint and slug for all requests to wfe (#5455)
Log endpoint and slug for all requests to wfe

Set logEvent.endpoint and slug so requests to "/" and 404 paths are logged

Fixes: #5432
2021-06-03 11:19:10 -06:00
Andrew Gabbitas 5b235bd8eb
Change ra.UpdateRegistration sig to match grpc (#5449)
Change ra.UpdateRegistration sig to match grpc

Fixes: #5403
2021-06-01 11:55:33 -06:00
Aaron Gable 7455a8a32d
Make RevokeCertificateWithReg wrappers passthroughs (#5445)
Update the signature of the RA's RevokeCertificateWithReg
method to exactly match that of the gRPC method it implements.
Remove all logic from the `RevokeCertificateWithReg` client
and server wrappers. Move the small amount of checking they
were performing directly into the server implementation.

Fixes #5440
2021-06-01 08:42:32 -07:00
Andrew Gabbitas 6b45dce5f1
Make ra.UpdateRegistration wrapper pass-through (#5431)
Part of: #5403
Fixes: #5398
2021-05-28 15:18:54 -06:00
Andrew Gabbitas 59bab8bac4
Make core.Registration.CreatedAt a *time.Time (#5422)
* Make core.Registration.CreatedAt a *time.time

Fixes: #5421
2021-05-21 13:44:56 -06:00
Andrew Gabbitas 9d99bb4471
Reject too-long CNs at new-order time (#5409)
Fixes #5391
2021-05-10 16:01:37 -07:00
Andrew Gabbitas 5fdacbeaa6
grpc wrapper removal: Turn ra.NewRegistration into passthrough (#5397)
Turn ra.NewRegistration into passthrough

Fixes #5343
2021-04-23 13:53:22 -06:00
Aaron Gable ef1d3c4cde
Standardize on `AssertMetricWithLabelsEquals` (#5371)
Update all of our tests to use `AssertMetricWithLabelsEquals`
instead of combinations of the older `CountFoo` helpers with
simple asserts. This coalesces all of our prometheus inspection
logic into a single function, allowing the deletion of four separate
helper functions.
2021-04-01 15:20:43 -07:00
Aaron Gable 1e11833478
wfe2: Check signatures before serving cert chains (#5273)
Add a check to `wfe2.Certificate` to ensure that the chain we select to
serve with the end-entity cert actually validates the end-entity's
signature. Add new test certificates, generated to match our actual
hierarchy. Update wfe2 tests to use the new test certificates, as well
as new mocks, in order to properly test the new check.

The new test certs and overhauled tests are necessary because the prior
wfe2 tests built and served chains that were not valid, and in
fact could not be valid because they were built with self-signed certs.

Fixes #5225
2021-02-09 09:09:49 -08:00
Aaron Gable 379826d4b5
WFE2: Improve support for multiple issuers & chains (#5247)
This change simplifies and hardens the wfe2's support for having
multiple issuers, and multiple chains for each issuer, configured
and loaded in memory.

The only config-visible change is replacing the old two separate config
values (`certificateChains` and `alternateCertificateChains`) with a
single value (`chains`). This new value does not require the user to
know and hand-code the AIA URLs at which the certificates are available;
instead the chains are simply presented as lists of files. If this new
config value is present, the old config values will be ignored; if it
is not, the old config values will be respected.

Behind the scenes, the chain loading code has been completely changed.
Instead of loading PEM bytes directly from the file, and then asserting
various things (line endings, no trailing bits, etc) about those bytes,
we now parse a certificate from the file, and in-memory recreate the
PEM from that certificate. This approach allows the file loading to be
much more forgiving, while also being stricter: we now check that each
certificate in the chain is correctly signed by the next cert, and that
the last cert in the chain is a self-signed root.

Within the WFE itself, most of the internal structure has been retained.
However, both the internal `issuerCertificates` (used for checking
that certs we are asked to revoke were in fact issued by us) and the
`certificateChains` (used to append chains to end-entity certs when
served to clients) have been updated to be maps keyed by IssuerNameID.
This allows revocation checking to not have to iterate through the
whole list of issuers, and also makes it easy to double-check that
the signatures on end-entity certs are valid before serving them. Actual
checking of the validity will come in a follow-up change, due to the
invasive nature of the necessary test changes.

Fixes #5164
2021-01-27 15:07:58 -08:00
Aaron Gable d9132102d1
WFE: Always use precert revocation path (#5227)
The PrecertificateRevocation flag is turned on everywhere, so the
else case is unused code. This change updates the WFE to always
use the PrecertificateRevocation code path, and deprecates the old
feature flag.

The TestRevokeCertificateWithAuthz method was deleted because
it is redundant with TestRevokeCertificateWithAuthorizations.

Fixes #5240
2021-01-20 16:00:11 -08:00
Aaron Gable 400bf3a02a
Allow WFEv1 to specify which issuer to use (#5222)
We intend to delete the v1 API (i.e. `wfe` and its associated codepaths)
in the near future, and as such are not giving it new features or
capabilities. However, before then we intend to allow the v2 API to
provide issuance both from our RSA and from our ECDSA intermediates.
The v1 API cannot gain such capability at the same time.

The CA doesn't know which frontend originated any given issuance
request, so we can't simply gate the single- or double-issuer behavior
based on that. Instead, this change introduces the ability for the
WFE (and the RA, which sits between the WFE and the CA) to request
issuance from a specific intermediate. If the specified intermediate is
not available in the CA, issuance will fail. If no intermediate is
specified (as is the case in requests coming from wfe2), it falls back
to selecting the issuer based on the algorithm of the public key to
be signed.

Fixes #5216
2021-01-20 09:22:03 -08:00
Aaron Gable 6c1f42fce7
WFE tests: simplify use of mock SAs (#5239)
This change deletes the (used, but not useful)
`mockSANoSuchRegistration` from the wfe2 tests, and updates all
places where the wfe tests create a mock SA to take the existing
mock SA as input instead of building another one from scratch from
the fakeclock.
2021-01-19 14:10:01 -08:00
Aaron Gable a214fb7757
Remove /issuer-cert endpoint from v2 API (#5215)
The /issuer-cert endpoint was a holdover from the v1 API, where
it is a critical part of the issuance flow. In the v2 issuance
flow, the issuer certificate is provided directly in the response
for the certificate itself. Thus, this endpoint is redundant.

Stats show that it receives approximately zero traffic (less than
one request per week, all of which are now coming from wget or
browser useragents). It also complicates the refactoring necessary
for the v2 API to support multiple issuers.

As such, it is a safe and easy decision to remove it.

Fixes #5196
2021-01-04 11:44:50 -08:00
Aaron Gable ebba443cad
Remove cmd.LoadCert in favor of core.LoadCert (#5165)
Having both of these very similar methods sitting around
only serves to increase confusion. This removes the last
few places which use `cmd.LoadCert` and replaces them
with `core.LoadCert`, and deletes the method itself.

Fixes #5163
2020-11-10 13:00:46 -08:00
Jacob Hoffman-Andrews ef955a561a
wfe: reject empty identifiers in new-authz and new-order (#5089)
Currently these are rejected at the RA. It's nicer to reject them one step earlier.

Fixes #5081
2020-09-15 09:42:33 -07:00
Jacob Hoffman-Andrews bf7c80792d
core: move to proto3 (#5063)
Builds on #5062
Part of #5050
2020-08-31 17:58:32 -07:00
Jacob Hoffman-Andrews 3c8b566a91
Remove references to authzv2 from WFE. (#5059)
We've now made the migration; no need to keep these vestiges around.
2020-08-28 11:43:36 -07:00
Jacob Hoffman-Andrews 1d31d60450
test: improve quality of some mocks (#5054)
As part of #5050, I'm updating some of the code in grpc/pb-marshaling.go
to move from nil checks to zero checks. In the process I'm introducing some
new zero checks, on things like challenge type, status, and token. This is
shaking out some places where our mocks have taken shortcuts by not
creating a "full" object including all fields that are normally present.

This PR updates our mocks and tests to provide more realistic objects in
all the places that broke when introducing those zero checks.
2020-08-27 09:42:22 -07:00
Aaron Gable 4d72f1f60e
RA: Update RPC interface to proto3 (#5039)
Updates the Registration Authority to use proto3 for its
RPC methods. This turns out to be a fairly minimal change,
as many of the RA's request and response messages are
defined in core.proto, and are therefore still proto2.

Fixes #4955
2020-08-24 13:00:41 -07:00
Roland Bracewell Shoemaker 7e342a545f
wfe/wfe2: only return 404 when certificate is actually not found (#4958)
Fixes #4950
2020-07-15 13:29:54 -07:00
Jacob Hoffman-Andrews 56d581613c
Update test/config. (#4923)
This copies over a number of features flags and other settings from
test/config-next that have been applied in prod.

Also, remove the config-next gate on various tests.
2020-07-01 17:59:14 -07:00
Matt Drollette 203ec13750
Return a no-store Cache-Control header for newNonce (#4908)
The spec specifies (https://tools.ietf.org/html/rfc8555#section-7.2)
that a `no-store` Cache-Control header is required in response to
getting a new nonce. This PR makes that change specifically but does
not modify other uses of the `no-cache` directive.

Fixes #4727
2020-06-26 12:02:27 -07:00
Jacob Hoffman-Andrews 36c1f1ab2d
Deprecate some feature flags (#4771)
Deprecate some feature flags.

These are all enabled in production.
2020-04-13 15:49:55 -07:00
Jacob Hoffman-Andrews 72deb5b798
gofmt code with -s (simplify) flag (#4763)
Found by golangci-lint's `gofmt` linter.
2020-04-08 17:25:35 -07:00
Jacob Hoffman-Andrews aa9ec70ef7
Remove deprecated HeaderMap reference. (#4762)
ResponseRecorder's HeaderMap field is deprecated:
https://godoc.org/net/http/httptest#ResponseRecorder

partial staticcheck cleanup: https://staticcheck.io/docs/checks#SA1019
2020-04-08 17:24:44 -07:00
Jacob Hoffman-Andrews 4df94d5215
Use responseWriter.Body.Bytes() (#4759)
staticcheck cleanup: https://staticcheck.io/docs/checks#S1030
2020-04-08 17:21:50 -07:00
Jacob Hoffman-Andrews de8855f15b
Use sort.Strings instead of sort.Sort (#4757)
staticcheck cleanup: https://staticcheck.io/docs/checks#S1032
2020-04-08 17:20:20 -07:00
Jacob Hoffman-Andrews 1278679afb
Handle mismatched URLs in key rollover. (#4752)
Fixes #4751
2020-04-07 19:21:02 -07:00
Jacob Hoffman-Andrews 3a1a08a10b
Remove unused code. (#4722)
Found by staticcheck.
2020-03-27 11:55:42 -07:00
alexzorin 93cb918ce4
wfe: implement alternate certificate chains (#4714)
Closes #4567.

Enabled in `config-next`.

This PR cross-signs the existing issuers (`test-ca-cross.pem`, `test-ca2-cross.pem`) with a new root (`test-root2.key`, `test-root2.pem` = *c2ckling cryptogr2pher f2ke ROOT*).

The cross-signed issuers are referenced in wfe2's configuration, beside the existing `certificateChains` key:

```json
    "certificateChains": {
      "http://boulder:4430/acme/issuer-cert": [ "test/test-ca2.pem" ],
      "http://127.0.0.1:4000/acme/issuer-cert": [ "test/test-ca2.pem" ]
    },
    "alternateCertificateChains": {
      "http://boulder:4430/acme/issuer-cert": [ "test/test-ca2-cross.pem" ],
      "http://127.0.0.1:4000/acme/issuer-cert": [ "test/test-ca2-cross.pem" ]
    },
```

When this key is populated, the WFE will send links for all alternate certificate chains available for the current end-entity certificate (except for the chain sent in the current response):

    Link: <http://localhost:4001/acme/cert/ff5d3d84e777fc91ae3afb7cbc1d2c7735e0/1>;rel="alternate"

For backwards-compatibility, not specifying a chain is the same as specifying `0`: `/acme/cert/{serial} == /acme/cert/{serial}/0` and `0` always refers to the default certificate chain for that issuer (i.e. the value of `certificateChains[aiaIssuerURL]`).
2020-03-24 12:43:26 -07:00
Roland Bracewell Shoemaker af5b41f4c2 WFE2: Fix GET API when used with MandatoryPOSTAsGET (#4656) 2020-01-23 14:24:05 -05:00
Daniel McCarney 925540d7be
Boulder specific API for GETing "stale" ACME resources. (#4645)
This builds on the work @sh7dm started in #4600. I primarily did some
refactoring, added enforcement of the stale check for authorizations and
challenges, and completed the unit test coverage.

A new Boulder-specific (e.g. not specified by ACME / RFC 8555) API is added for
fetching order, authorization, challenge, and certificate resources by URL
without using POST-as-GET. Since we intend this API to only be used by humans
for debugging and we want to ensure ACME client devs use the standards compliant
method we restrict the GET API to only allowing access to "stale" resources
where the required staleness is defined by the WFE2 "staleTimeout"
configuration value (set to 5m in dev/CI).

Since authorizations don't have a creation date tracked we add
a `authorizationLifetimeDays` and `pendingAuthorizationLifetimeDays`
configuration parameter to the WFE2 that matches the RA's configuration. These
values are subtracted from the authorization expiry to find the creation date to
enforce the staleness check for authz/challenge GETs.

One other note: Resources accessed via the GET API will have Link relation URLs
pointing to the standard ACME API URL. E.g. a GET to a stale challenge will have
a response header with a link "up" relation URL pointing at the POST-as-GET URL
for the associated authorization. I wanted to avoid complicating
`prepAuthorizationForDisplay` and `prepChallengeForDisplay` to be aware of the
GET API and update or exclude the Link relations. This seems like a fine
trade-off since we don't expect machine consumption of the GET API results
(these are for human debugging).

Replaces #4600
Resolves #4577
2020-01-15 09:56:48 -05:00
Daniel McCarney 53171f4674 wfe2: cleanup some more authz1 leftovers. (#4640)
After the prev. cleanup of legacy authz1 bits the `authzLookupFunc`
interface and the associated `handleAuthorization` function are only
used in one place for handling authz2 resources. This commit cleans
this now unneeded abstraction up (and also removes the "V2" suffix
from the challenge and authz handlers).
2020-01-13 11:26:23 -08:00
Daniel McCarney f1894f8d1d
tidy: typo fixes flagged by codespell (#4634) 2020-01-07 14:01:26 -05:00
Roland Bracewell Shoemaker 5b2f11e07e Switch away from old style statsd metrics wrappers (#4606)
In a handful of places I've nuked old stats which are not used in any alerts or dashboards as they either duplicate other stats or don't provide much insight/have never actually been used. If we feel like we need them again in the future it's trivial to add them back.

There aren't many dashboards that rely on old statsd style metrics, but a few will need to be updated when this change is deployed. There are also a few cases where prometheus labels have been changed from camel to snake case, dashboards that use these will also need to be updated. As far as I can tell no alerts are impacted by this change.

Fixes #4591.
2019-12-18 11:08:25 -05:00
Daniel McCarney a386877c3e
WFE2: allow POST-as-GET for directory & newNonce endpoints. (#4595)
RFC 8555 §6.3 says the server's directory and newNonce endpoints should
support POST-as-GET as well as GET.
2019-12-04 17:29:01 -05:00
Daniel McCarney fde145ab96
RA: implement stricter email validation. (#4574)
Prev. we weren't checking the domain portion of an email contact address
very strictly in the RA. This updates the PA to export a function that
can be used to validate the domain the same way we validate domain
portions of DNS type identifiers for issuance.

This also changes the RA to use the `invalidEmail` error type in more
places.

A new Go integration test is added that checks these errors end-to-end
for both account creation and account update.
2019-11-22 13:39:31 -05:00
Roland Bracewell Shoemaker 2de47bcdee WFE/WFE2: Remove old authz/challenge support (#4486)
Does what it says on the tin. Also requires some mocks changes that will also be
used by RA changes in the next part of this change series.
2019-10-17 10:19:04 -04:00
Daniel McCarney fdbf87679b
wfe/wfe2: handle bad authz2 IDs as malformed req. (#4453)
Prev. the WFE2 would return a 500 error in the case where an
authorization ID was invalid. The WFE1 would return a 404. Returning
a malformed request problem reports the true cause of the error as
an invalid client request.
2019-09-27 17:27:02 -04:00
Daniel McCarney 1cd9733c24
WFE2: allow revocation of precertificates. (#4433)
When the `features.PrecertificateRevocation` feature flag is enabled the WFE2
will allow revoking certificates for a submitted precertificate. The legacy WFE1
behaviour remains unchanged (as before (pre)certificates issued through the V1
API will be revocable with the V2 API).

Previously the WFE2 vetted the certificate from the revocation request by
looking up a final certificate by the serial number in the requested
certificate, and then doing a byte for byte comparison between the stored and
requested certificate.

Rather than adjust this logic to handle looking up and comparing stored
precertificates against requested precertificates (requiring new RPCs and an
additional round-trip) we choose to instead check the signature on the requested
certificate or precertificate and consider it valid for revocation if the
signature validates with one of the WFE2's known issuers. We trust the integrity
of our own signatures.

An integration test that performs a revocation of a precertificate (in this case
one that never had a final certificate issued due to SCT embedded errors) with
all of the available authentication mechanisms is included.

Resolves https://github.com/letsencrypt/boulder/issues/4414
2019-09-16 16:40:07 -04:00
Jacob Hoffman-Andrews d077d3346e wfe/wfe2: remove AllowAuthzDeactivation flag. (#4345)
Fixes #4339
2019-07-17 16:30:27 -04:00
Jacob Hoffman-Andrews a4fc143a54 wfe/wfe2: clean up AcceptRevocationReason flag. (#4342)
Fixes #4340
2019-07-17 10:33:47 -04:00
Jacob Hoffman-Andrews 71eea294b9
Use HandleFunc to process authzv2s (in wfe2) (#4341)
Similar to #4334, this fixes a bug where authzs with a randomly generated id
starting with "v2" would incorrectly get treated as v2 authzs.

It accomplishes this change by splitting out v2 authzs into their own path and
using our regular HTTP mux to split them out. It uses a "-v3" name in the
public-facing URLs to avoid confusion.
2019-07-16 11:46:33 -07:00
Roland Bracewell Shoemaker af41bea99a Switch to more efficient multi nonce-service design (#4308)
Basically a complete re-write/re-design of the forwarding concept introduced in
#4297 (sorry for the rapid churn here). Instead of nonce-services blindly
forwarding nonces around to each other in an attempt to find out who issued the
nonce we add an identifying prefix to each nonce generated by a service. The
WFEs then use this prefix to decide which nonce-service to ask to validate the
nonce.

This requires a slightly more complicated configuration at the WFE/2 end, but
overall I think ends up being a way cleaner, more understandable, easy to
reason about implementation. When configuring the WFE you need to provide two
forms of gRPC config:

* one gRPC config for retrieving nonces, this should be a DNS name that
resolves to all available nonce-services (or at least the ones you want to
retrieve nonces from locally, in a two DC setup you might only configure the
nonce-services that are in the same DC as the WFE instance). This allows
getting a nonce from any of the configured services and is load-balanced
transparently at the gRPC layer. 
* a map of nonce prefixes to gRPC configs, this maps each individual
nonce-service to it's prefix and allows the WFE instances to figure out which
nonce-service to ask to validate a nonce it has received (in a two DC setup
you'd want to configure this with all the nonce-services across both DCs so
that you can validate a nonce that was generated by a nonce-service in another
DC).

This balancing is implemented in the integration tests.

Given the current remote nonce code hasn't been deployed anywhere yet this
makes a number of hard breaking changes to both the existing nonce-service
code, and the forwarding code.

Fixes #4303.
2019-06-28 12:58:46 -04:00
Daniel McCarney 7f01d1274e
wfe2: consistently prep account resources for display. (#4293) 2019-06-25 14:26:25 -04:00
Roland Bracewell Shoemaker 059112640b wfe: Use RawURLEncoding for authz2 challenge IDs (#4280) 2019-06-21 09:55:10 -04:00
Roland Bracewell Shoemaker 4e10063ceb
Fix challenge up Link relation header (#4264)
and adds a test to check the relation is what we expect.

Fixes #4262.
2019-06-18 15:20:51 -07:00
Daniel McCarney fea7106927
WFE2: Add feature flag for Mandatory POST-As-GET. (#4251)
In November 2019 we will be removing support for legacy pre RFC-8555
unauthenticated GET requests for accessing ACME resources. A new
`MandatoryPOSTAsGET` feature flag is added to the WFE2 to allow
enforcing this change. Once this feature flag has been activated in Nov
we can remove both it and the WFE2 code supporting GET requests.
2019-06-07 08:36:13 -04:00
Daniel McCarney 584702bdce
WFE2: Implement badRevocationReason problem type. (#4252)
Previously we were returning a Malformed problem type where RFC 8555
mandates the use of badRevocationReason and encourages including the
allowed reasons in the problem detail.
2019-06-06 17:08:41 -04:00
Roland Bracewell Shoemaker 4ca01b5de3
Implement standalone nonce service (#4228)
Fixes #3976.
2019-06-05 10:41:19 -07:00
Daniel McCarney 7dd176e9a4 Implement suberrors for policy blocked names. (#4234)
When validating a CSR's identifiers, or a new order's identifiers there may be more than one identifier that is blocked by policy. We should return an error that has suberrors identifying each bad identifier individually in this case.

Updates https://github.com/letsencrypt/boulder/issues/4193
Resolves https://github.com/letsencrypt/boulder/issues/3727
2019-05-31 15:00:17 -07:00
Roland Bracewell Shoemaker 6f93942a04 Consistently used stdlib context package (#4229) 2019-05-28 14:36:16 -04:00
Roland Bracewell Shoemaker 4d40cf58e4
Enable integration tests for authz2 and fix a few bugs (#4221)
Enables integration tests for authz2 and fixes a few bugs that were flagged up during the process. Disables expired-authorization-purger integration tests if config-next is being used as expired-authz-purger expects to purge some stuff but doesn't know about authz2 authorizations, a new test will be added with #4188.

Fixes #4079.
2019-05-23 15:06:50 -07:00
Daniel McCarney ea9871de1e core: split identifier types into separate package. (#4225)
This will allow implementing sub-problems without creating a cyclic
dependency between `core` and `problems`.

The `identifier` package is somewhat small/single-purpose and in the
future we may want to move more "ACME" bits beyond the `identifier`
types into a dedicated package outside of `core`.
2019-05-23 13:24:41 -07:00
Kleber Correia 51d56023e8 wfe2: Do not return existing deactivated accts from NewAccount (#4187)
According to the current draft, "Once an account is deactivated, the server MUST NOT accept further requests authorized by that account's key."
This commit, implements the correct behavior by returning unauthorized problem for newAccount POSTs matching deactivated accounts.
2019-05-02 14:17:20 -04:00
Roland Bracewell Shoemaker d06c6a5285
New style authorizations: All SA methods (#4134)
This PR implements new SA methods for handling authz2 style authorizations and updates existing SA methods to count and retrieve them where applicable when the `NewAuthorizationSchema` feature is enabled.

Fixes #4093
Fixes #4082
Updates #4078 
Updates #4077
2019-04-24 09:40:38 -07:00
Roland Bracewell Shoemaker 7ff30cf857 Remove account ID in WFE2 if feature enabled (#4160)
This helps encourage ACME client developers to use the RFC 8555
specified `Location` header instead.

Fixes #4136.
2019-04-17 13:38:25 -04:00
Jacob Hoffman-Andrews 935df44851 Move "Combinations" support to WFE1. (#4155)
Early ACME drafts supported a notion of "combinations" of challenges
that had to be completed together. This was removed from subsequent
drafts. Boulder has only ever supported "combinations" that exactly map
to the list of challenges, 1 for 1.

This removes all the plumbing for combinations, and adds a list of
combinations to the authz JSON right before marshaling it in WFE1.
2019-04-16 11:31:51 -07:00
Jacob Hoffman-Andrews ff3129247d Put features.Reset in unitest setup functions. (#4129)
Previously we relied on each instance of `features.Set` to have a
corresponding `defer features.Reset()`. If we forget that, we can wind
up with unexpected behavior where features set in one test case leak
into another test case. This led to the bug in
https://github.com/letsencrypt/boulder/issues/4118 going undetected.

Fix #4120
2019-04-02 10:14:38 -07:00
Daniel McCarney f694852b43 WFE2: Fix index link relation target. (#4107) 2019-03-11 10:08:39 -07:00
Roland Bracewell Shoemaker 51f29b9953
Implement WFE retrieval logic for v2 authorizations (#4085)
This changeset implements the logic required for the WFE to retrieve v2 authorizations and their associated challenges while still maintaining the logic to retrieve old authorizations/challenges. Challenge IDs for v2 authorizations are obfuscated using a pretty simply scheme in order to prevent hard coding of indexes. A `V2` field is added to the `core.Authorization` object and populated using the existing field of the same name from the protobuf for convenience. v2 authorizations and challenges use a `v2` prefix in all their URLs in order to easily differentiate between v1 and v2 URLs (e.g. `/acme/authz/v2/asd` and `/acme/challenge/v2/asd/123`), once v1 authorizations cease to exist this prefix can be safely removed. As v2 authorizations use int IDs this change switches from string IDs to int IDs, this mainly only effects tests.

Integration tests are put off for #4079 as they really need #4077 and #4078 to be properly effective.

Fixes #4041.
2019-02-26 13:14:05 -08:00
Daniel McCarney b8ef85352b WFE2: Always send Link header for directory URL. (#4071)
All HTTP responses for requests to resources (other than the directory
resource) should get a `Link` header with the `"index"` relation that
points to the ACME directory URL. See
https://tools.ietf.org/html/draft-ietf-acme-acme-18#section-7.1
2019-02-21 11:04:46 -08:00
Daniel McCarney c105cfa5de WFE2: Don't allow finalizing pending orders, impl BadOrderState err type (#4075)
We've been using the newer "ready" order status for longer than the lifetime of any previously "pending" orders. I believe this means we can drop the legacy allowance for finalizing pending orders and enforce finalization only occur for "ready" orders without any feature flags. This is implemented in [c85d4b0](c85d4b097b).

There is a new error type added in the draft spec (`orderNotReady`) that should be returned to clients that finalize an order in state other than "ready". This is implemented in [6008202](6008202357).

Resolves #4073
2019-02-21 11:00:15 -08:00
Roland Bracewell Shoemaker 232a5f828f Fix ineffectual assignments (#4052)
* in boulder-ra we connected to the publisher and created a publisher gRPC client twice for no apparent reason
* in the SA we ignored errors from `getChallenges` in `GetAuthorizations` which could result in a nil challenge being returned in an authorization
2019-02-13 15:39:58 -05:00
Jacob Hoffman-Andrews bf7f638a25 Set "Created" field for new-order. (#4013)
This will allow us to connect new-order requests with the order URLs
that are created as a result.

Also ensure the Requester is filled in for new-acct requests that return
an existing account (it's already filled in for new-acct requests that
create an account).
2019-01-17 09:45:56 -05:00
Daniel McCarney 52395a061a WFE2: Remove ACME13KeyRollover feature and legacy code. (#3999)
The draft 13 ACME v2 key change behaviour is now mandatory and we can remove the legacy WFE2 code.
2019-01-15 15:40:01 -08:00
Jacob Hoffman-Andrews 1563419cfb
Shrink byte size of WFE request logs. (#3997)
- Log the simple, non-whitespace-containing fields as positional
parameters to avoid the JSON overhead for them.
- Log latency in milliseconds rather than seconds (saves "0.").
- Hoist some fields from the "Extra" sub-object and give
  them shorter names. This saves the bytes for rendering the "Extra"
  field plus the bytes for the longer names.

Example output from integration tests:

Before (1687 bytes):

I205230 boulder-wfe JSON={"Endpoint":"/directory","Method":"GET","UserAgent":"Boulder integration tester","Latency":0.001,"Code":0}
I205230 boulder-wfe JSON={"Endpoint":"/acme/new-reg","Method":"HEAD","Error":"405 :: malformed :: Method not allowed","UserAgent":"Boulder integration tester","Latency":0,"Code":405}
I205230 boulder-wfe JSON={"Endpoint":"/acme/new-reg","Method":"POST","Requester":611,"Contacts":[],"UserAgent":"Boulder integration tester","Latency":0.025,"Code":201,"Payload":"{\n  \"resource\": \"new-reg\"\n}"}
I205230 boulder-wfe JSON={"Endpoint":"/acme/reg/","Slug":"611","Method":"POST","Requester":611,"Contacts":[],"UserAgent":"Boulder integration tester","Latency":0.021,"Code":202,"Payload":"{\n  \"status\": \"valid\", \n  \"resource\": \"reg\", \n  \"agreement\": \"http://boulder:4000/terms/v1\", \n  \"key\": {\n    \"e\": \"AQAB\", \n    \"kty\": \"RSA\", \n    \"n\": \"r1zCJC8Muw5K8ti-pjojivHxyNxOZye-N5aX_i7kBiHrAOp9qxgQUHUyU3COCjFPrSzScTpKoIyCwdL7x-1mPX3pby7CzGugtY9da_LZkDmsDE8LIuQkZ_wRLyh1103OQZEd71AlddMx1iwLLVl4UTICoJFUfYvXHvkqmsE5xhBPJhl-SdSrJM6F7Kn7k0WycA5ig_QPbjVbzJlQq-C65iGDJtc_LvY0FFF4exThZM7xsvucJywJMHCEWZUktm9YB-CBNA1gVbL52u22jQpX-MN52UVdqSh9ZipoJLtxKjZx31DHB_bcdgtJ8YGIE4lY_ZAax1Ut-a5WTJvVq2Hk8w\"\n  }\n}"}
I205230 boulder-wfe JSON={"Endpoint":"/acme/new-authz","Method":"POST","Requester":611,"Contacts":[],"UserAgent":"Boulder integration tester","Latency":0.031,"Code":201,"Payload":"{\n  \"identifier\": {\n    \"type\": \"dns\", \n    \"value\": \"rand.18fe4d73.xyz\"\n  }, \n  \"resource\": \"new-authz\"\n}","Extra":{"AuthzID":"PgF1JQ3TK6c1FR0wVdm_mYows_xWSsyYgyezSvSNI-0","Identifier":{"type":"dns","value":"rand.18fe4d73.xyz"}}}

After (1406 bytes):

I210117 boulder-wfe GET /directory 0 0 0 0.0.0.0 JSON={"ua":"Boulder integration tester"}
I210117 boulder-wfe HEAD /acme/new-reg 0 405 0 0.0.0.0 JSON={"Error":"405 :: malformed :: Method not allowed","ua":"Boulder integration tester"}
I210117 boulder-wfe POST /acme/new-reg 676 201 23 0.0.0.0 JSON={"Contacts":[],"ua":"Boulder integration tester","Payload":"{\n  \"resource\": \"new-reg\"\n}"}
I210117 boulder-wfe POST /acme/reg/ 676 202 23 0.0.0.0 JSON={"Slug":"676","Contacts":[],"ua":"Boulder integration tester","Payload":"{\n  \"status\": \"valid\", \n  \"resource\": \"reg\", \n  \"agreement\": \"http://boulder:4000/terms/v1\", \n  \"key\": {\n    \"e\": \"AQAB\", \n    \"kty\": \"RSA\", \n    \"n\": \"zXSFAzdzwwFGjNysmG0YE7MxAwQ8JkkvLQ7Qs7xB1h5kFM_F-W2jxYEmrRTrA0ylfuzb4RQMBrsLfv0XV8rsDIuP_t92ADBjfd25ajuuia9EGrhpHitFimEUlZjsqGQp8F49xLhDMAqm1SLBY_k1pY8TKSLHeyOyLYIKLaL3Ra9yZ63qB65oGuNhXroKqqx7nUjyZtqtUV5NUPvPgvhJgXgYKMjck3jXWgr4ZGqYyJQqNqydYSk3uJGfruChakZThwl3vbH8aUPaeoXcvPA8KaQl56JUf7jAVY3n9qKKb5mgT96vDKWUpJaI5YE1rMZIJfkaFK-ZZIhFeeKCSsSJlQ\"\n  }\n}"}
I210117 boulder-wfe POST /acme/new-authz 676 201 35 0.0.0.0 JSON={"Contacts":[],"ua":"Boulder integration tester","Payload":"{\n  \"identifier\": {\n    \"type\": \"dns\", \n    \"value\": \"rand.14ebdfd1.xyz\"\n  }, \n  \"resource\": \"new-authz\"\n}","Created":"Z-soxIEhsGlMK3GYyDqYrSlxDFEeH6q3mrd6aoi2iIs","DNSName":"rand.14ebdfd1.xyz"}
2019-01-10 09:24:06 -08:00
Jacob Hoffman-Andrews a7da3fc58c Update tests. 2019-01-09 15:00:58 -08:00
Daniel McCarney b0f407dcf0 RA: Remove deprecated UpdateAuthorization RPC. (#3993)
Staging and prod both deployed the PerformValidationRPC feature flag. All running WFE/WFE2 instances are using the more accurately named PerformValidation RPC and we can strip out the old UpdateAuthorization bits. The feature flag for PerformValidationRPC remains until we clean up the staging/prod configs.

Resolves #3947 and completes the last of #3930
2019-01-07 16:35:27 -08:00
Daniel McCarney e5b8d530b7
wfe2: Return Status 200 for HEAD to new-nonce endpoint. (#3992)
Previously we mistakenly returned status 204 (no content) for all
requests to new-nonce, including HEAD. This status should only be used
for GET requests.

When the `HeadNonceStatusOK` feature flag is enabled we will now return
the correct status for HEAD requests. When the flag is disabled we return
status 204 to preserve backwards compatibility.
2019-01-07 12:58:30 -05:00
Daniel McCarney 87d97cc252
Add WFE unit tests for RA.UpdateAuthorization/PerformValidation errs. (#3977) 2018-12-10 16:31:59 -05:00
Daniel McCarney 8f5de538c1
RA: Add PerformValidation RPC to replace UpdateAuthorization. (#3942)
The existing RA `UpdateAuthorization` RPC needs replacing for
two reasons:

1. The name isn't accurate - `PerformValidation` better captures
the purpose of the RPC.
2. The `core.Challenge` argument is superfluous since Key 
Authorizations are not sent in the initiation POST from the client 
anymore. The corresponding unmarshal and verification is now 
removed. Notably this means broken clients that were POSTing
the wrong thing and failing pre-validation will now likely fail 
post-validation.

To remove `UpdateAuthorization` the new `PerformValidation` 
RPC is added alongside the old one. WFE and WFE2 are 
updated to use the new RPC when the perform validation
feature flag is enabled. We can remove 
`UpdateAuthorization` and its associated wrappers once all 
WFE instances have been updated.

Resolves https://github.com/letsencrypt/boulder/issues/3930
2018-11-28 10:12:47 -05:00
Roland Shoemaker 75728ea2b5 Review feedback 2018-11-14 12:17:26 -08:00
Roland Shoemaker ad1843c47f Check authorization status at the WFE/2 instead of RA 2018-11-13 12:04:56 -08:00
Daniel McCarney 1398377eba
ACME v2: Optional POST-as-GET support. (#3883)
This allows POST-as-GET requests to Orders, Authorizations, Challenges, Certificates and Accounts. Legacy GET support remains for Orders, Authorizations, Challenges and Certificates. Legacy "POST {}" support for Accounts remains.

Resolves https://github.com/letsencrypt/boulder/issues/3871
2018-10-22 18:03:47 -04:00
Roland Bracewell Shoemaker 7fd3d30bdf Reject revocation requests for expired certs (#3896)
Fixes #3894.
2018-10-22 16:49:15 -04:00
Daniel McCarney 3319246a97 Dev/CI: Add Go 1.11.1 builds (#3888)
Resolves https://github.com/letsencrypt/boulder/issues/3872

**Note to reviewers**: There's an outstanding bug that I've tracked down to the `--load` stage of the integration tests that results in one of the remote VA instances in the `test/config-next` configuration under Go 1.11.1 to fail to cleanly shut down. I'm working on finding the root cause but in the meantime I've disabled `--load` during CI so we can unblock moving forward with getting Go 1.11.1 in dev/CI. Tracking this in https://github.com/letsencrypt/boulder/issues/3889
2018-10-19 09:38:20 -07:00
Roland Bracewell Shoemaker a9a0846ee9
Remove checks for deployed features (#3881)
Removes the checks for a handful of deployed feature flags in preparation for removing the flags entirely. Also moves all of the currently deprecated flags to a separate section of the flags list so they can be more easily removed once purged from production configs.

Fixes #3880.
2018-10-17 20:29:18 -07:00
Jacob Hoffman-Andrews aac0e3d122 Return 404 for missing authz ids. (#3858)
Fixes #1199.
2018-09-17 17:07:00 -07:00
Felix Fontein 788ea1074d WFE2: use draft-14's alreadyRevoked error. (#3824) 2018-08-23 11:58:27 -04:00
Daniel McCarney 7de72eede6
WFE2: Add unit tests for draft-12/draft-13 intercompat. (#3816)
The implementation of the `features.ACME13KeyRollover` flag was written
with the intent to allow client developers to send both the `"newKey"`
and `"oldKey"` and be interoperable between both feature flag states. We
should have an explicit unit test for this to be sure it works as
intended.
2018-08-10 15:24:45 -04:00
Daniel McCarney 0cb28c9e02
WFE2: Implement draft-13 keyrollover with feature flag. (#3813)
ACME draft-13 changed the inner JWS' body to contain the old key
that signed the outer JWS. Because this is a backwards incompatible
change with the draft-12 ACME v2 key rollover we introduce a new feature
flag `features.ACME13KeyRollover` and conditionally use the old or new
key rollover semantics based on its value.
2018-08-07 15:27:25 -04:00
Roland Bracewell Shoemaker 52e5f20806 wfe2: return existing account in body (#3811)
Fixes #3801.
2018-08-06 09:01:49 -04:00
Joel Sing f8a023e49c Remove various unnecessary uses of fmt.Sprintf (#3707)
Remove various unnecessary uses of fmt.Sprintf - in particular:

- Avoid calls like t.Error(fmt.Sprintf(...)), where t.Errorf can be used directly.

- Use strconv when converting an integer to a string, rather than using
  fmt.Sprintf("%d", ...). This is simpler and can also detect type errors at
  compile time.

- Instead of using x.Write([]byte(fmt.Sprintf(...))), use fmt.Fprintf(x, ...).
2018-05-11 11:55:25 -07:00
Daniel ac6672bc71
Revert "Revert "V2: implement "ready" status for Order objects (#3614)" (#3643)"
This reverts commit 3ecf841a3a.
2018-04-12 13:20:47 -04:00
Jacob Hoffman-Andrews 3ecf841a3a Revert "V2: implement "ready" status for Order objects (#3614)" (#3643)
This reverts commit 1d22f47fa2.

According to
https://github.com/letsencrypt/boulder/pull/3614#issuecomment-380615172,
this broke Certbot's tests. We'll investigate, and then roll forward
once we understand what broke.
2018-04-12 10:46:57 -04:00
Daniel McCarney 1d22f47fa2 V2: implement "ready" status for Order objects (#3614)
* SA: Add Order "Ready" status, feature flag.

This commit adds the new "Ready" status to `core/objects.go` and updates
`sa.statusForOrder` to use it conditionally for orders with all valid
authorizations that haven't been finalized yet. This state is used
conditionally based on the `features.OrderReadyStatus` feature flag
since it will likely break some existing clients that expect status
"Processing" for this state. The SA unit test for `statusForOrder` is
updated with a "ready" status test case.

* RA: Enforce order ready status conditionally.

This commit updates the RA to conditionally expect orders that are being
finalized to be in the "ready" status instead of "pending". This is
conditionally enforced based on the `OrderReadyStatus` feature flag.
Along the way the SA was changed to calculate the order status for the
order returned in `sa.NewOrder` dynamically now that it could be
something other than "pending".

* WFE2: Conditionally enforce order ready status for finalization.

Similar to the RA the WFE2 should conditionally enforce that an order's
status is either "ready" or "pending" based on the "OrderReadyStatus"
feature flag.

* Integration: Fix `test_order_finalize_early`.

This commit updates the V2 `test_order_finalize_early` test for the
"ready" status. A nice side-effect of the ready state change is that we
no longer invalidate an order when it is finalized too soon because we
can reject the finalization in the WFE. Subsequently the
`test_order_finalize_early` testcase is also smaller.

* Integration: Test classic behaviour w/o feature flag.

In the previous commit I fixed the integration test for the
`config/test-next` run that has the `OrderReadyStatus` feature flag set
but broke it for the `config/test` run without the feature flag.

This commit updates the `test_order_finalize_early` test to work
correctly based on the feature flag status in both cases.
2018-04-11 10:31:25 -07:00
Daniel McCarney 4284c03c62 Stricter V2 Account Update. (#3592)
This commit removes the possibility of unmarshaling the `Agreement`
field of a new account request. This is a legacy V1 concept and has
no bearing on ACMEv2. Instead a specific one-off struct that only
contains the fields we wish to allow update for (Contact and Status) is
used to unmarshal the new account request.
2018-03-23 12:59:05 -07:00
Daniel McCarney 476238ac85 Don't return "Agreement" in V2 account objects. (#3591)
This commit updates the WFE2 to remove the "Agreement" value on V2 account objects before returning them to the user. This field is not defined in the V2 specification and we should not be returning it.

The V2 `TermsOfServiceAgreed` field is marked optional, and for Let's Encrypt purposes it doesn't make much sense to write it in returned Account objects because the value will necessarily be true 100% of the time. We never create an account unless the request has `TermsOfServiceAgreed: true`.

Resolves https://github.com/letsencrypt/boulder/issues/3590
2018-03-23 09:48:07 -07:00
Daniel McCarney 17922a6d2d
Add CAAIdentities and Website to /directory "meta". (#3588)
This commit updates the WFE and WFE2 to have configuration support for
setting a value for the `/directory` object's "meta" field's
optional "caaIdentities" and "website" fields. The config-next wfe/wfe2
configuration are updated with values for these fields. Unit tests are
updated to check that they are sent when expected and not otherwise.

Bonus content: The `test.AssertUnmarshaledEquals` function had a bug
where it would consider two inputs equal when the # of keys differed.
This commit also fixes that bug.
2018-03-22 16:12:43 -04:00
Daniel McCarney 866627ee29 Return descriptive error when SCTs policy can't be met. (#3586)
This commit updates CTPolicy & the RA to return a distinct error when
the RA is unable to fetch the required SCTs for a certificate when
processing an issuance. This error type is plumbed up to the WFE/WFE2
where the `web/probs.go` code converts it into a server internal error
with a suitable user facing error.
2018-03-22 13:10:08 -07:00
Daniel McCarney 7e5f22dd8d Allow Content-Type header in V2 CORS. (#3559)
We are soon enforcing that V2 POST requests have a `Content-Type` of
`application/jose+json` to match ACME specification requirement. For
CORS this requires adding the `Content-Type` to the
`Access-Control-Allow-Headers` CORS field because the JOSE content type
is not one that can be used by a "simple header" whitelisted by default.

This commit adds `Access-Control-Allow-Headers: Content-Type` where
required and updates unit tests accordingly.
2018-03-14 15:32:22 -07:00
Jacob Hoffman-Andrews d654675223 Remove BaseURL from WFE config. (#3540)
For a long time now the WFE has generated URLs based on the incoming
request rather than a hardcoded BaseURL. BaseURL is no longer set in the
prod configs.

This also allows factoring out relativeEndpoint into the web package.
2018-03-09 11:04:02 +00:00
Daniel McCarney 49d55d9ab5 Make POSTing KeyAuthorization optional, V2 don't echo it. (#3526)
This commit updates the RA to make the notion of submitting
a KeyAuthorization value as part of the ra.UpdateAuthorization call
optional. If set, the value is enforced against expected and an error is
returned if the provided authorization isn't correct. If it isn't set
the RA populates the field with the computed authorization for the VA to
enforce against the value it sees in challenges. This retains the legacy
behaviour of the V1 API. The V2 API will never unmarshal a provided
key authorization.

The ACMEv2/WFEv2 prepChallengeForDisplay function is updated to strip
the ProvidedKeyAuthorization field before sending the challenge object
back to a client. ACMEv1/WFEv1 continue to return the KeyAuthorization
in challenges to avoid breaking clients that are relying on this legacy
behaviour.

For deployability ease this commit retains the name of the
core.Challenge.ProvidedKeyAuthorization field even though it should
be called core.Challenge.ComputedKeyAuthorization now that it isn't
set based on the client's provided key authz. This will be easier as
a follow-up change.

Resolves #3514
2018-03-06 20:33:01 +00:00
Jacob Hoffman-Andrews eb23cb3ffc Remove "Terminated request" / "Successful request" (#3484)
The WFE logs these with every request, but with #3483,
they aren't necessary; everything other than 2xx is a failed request.
2018-02-28 15:16:36 -08:00
Jacob Hoffman-Andrews 8cf8c44919 Change finalize order path (#3480)
This puts puts the path for order finalization at the beginning of the URL, rather than the end, making it easier to generate stats about. It also allows us to split out GetOrder and FinalizeOrder from the previous "Order" function that combined some unrelated code.

Fixes #3440 
Fixes #3439 (order finalization now has its own stats like the other endpoints do)
2018-02-28 09:50:12 -05:00
Roland Bracewell Shoemaker 1231f577d0 Allow revocation of certificate by issuing account and add integration tests (#3390)
Fixes #3331 and #3330.
2018-01-29 13:23:20 -08:00
Roland Bracewell Shoemaker 88aa44e43d Reject NotBefore and NotAfter if sent in NewOrder Request (#3397)
Fixes #3363.
2018-01-29 10:50:39 -08:00
Roland Bracewell Shoemaker d916ccc9ed Only return nonce for non-GET unless req is for new-nonce (#3400) 2018-01-29 10:03:52 -08:00
Daniel McCarney d6a33d1108 Return full cert chain for V2 cert GET. (#3366)
This commit implements a mapping from certificate AIA Issuer URL to PEM
encoded certificate chain. GET's to the V2 Certificate endpoint will
return a full PEM encoded certificate chain in addition to the leaf cert
using the AIA issuer URL of the leaf cert and the configured mapping.

The boulder-wfe2 command builds the chain mapping by reading the
"wfe" config section's 'certificateChains" field, specifying a list
of file paths to PEM certificates for each AIA issuer URL. At startup
the PEM file contents are ready, verified and separated by a newline.
The resulting populated AIA issuer URL -> PEM cert chain mapping is
given to the WFE for use with the Certificate endpoint.

Resolves #3291
2018-01-19 11:23:44 -08:00
Roland Bracewell Shoemaker 230b397403 Fix wfe2 key rollover (#3373)
Fixes #3340.

Required some monkeying around with the test keys used.
2018-01-18 14:31:48 -08:00
Daniel McCarney f969847070 Delete unused WFE/WFE2 cache configuration params. (#3360)
This commit removes `CertCacheDuration`, `CertNoCacheExpirationWindow`,
`IndexCacheDuration` and `IssuerCacheDuration`. These were read from
config values that weren't set in config/config-next into WFE struct
fields that were never referenced in any code.
2018-01-12 15:54:02 -08:00
Daniel McCarney 191ad117dc Add "Location" to WFEv2 Access-Control-Expose-Headers. (#3337)
This updates CORS to allow in-browser JS clients to access the
Location response header.

Resolves #3334

Thanks to @tappie for reporting!
2018-01-08 10:51:39 -08:00
Jonathan Rudenberg aae455da21 Add Location header to WFE2 finalize response (#3336) 2018-01-08 09:38:30 -08:00
Jacob Hoffman-Andrews 4ba5205e81 Remove /terms redirect. (#3326)
Fixes #3325
2018-01-05 12:06:14 -08:00
Daniel McCarney b73d911f9d Return correct response to existing newAccount reqs. (#3329)
Prior to this commit the WFE2 returned a HTTP 409 status with
a malformed problem body when a newAccount request arrived signed with
the same key as is used with an existing account. Per draft-09 this
should be a HTTP 200 OK response. This is what Pebble implements as
well.

This commit updates the WFE2 and tests to match draft-09 behaviour in
this regard.

An outdated TODO is also removed. The case where an error other
than berrors.NotFound is returned is handled correctly.

Resolves #3327
2018-01-05 12:05:25 -08:00
Daniel McCarney ca54d9758f More small WFE2 fixes (#3296)
- Fixes two places WFE2 returned http.StatusAccepted when it should return http.StatusOK
- Removes the legacy challenge "URI" field in place of "URL"
2017-12-20 10:34:03 -08:00
Jacob Hoffman-Andrews 52bb0aa7ba Use lowercase for the "status" field of registrations (#3293) 2017-12-19 15:48:13 -08:00
Daniel McCarney b489669d73 Implement "onlyReturnExisting" for new-account. (#3295)
This commit adds support for the "onlyReturnExisting" field of
new-account requests. If present & true then new-account will check if
an existing account for the provided key exists. If it does a Location
header is returned with the existing account's URL. If it does not exist
an error is returned. This is contrary to the "onlyReturnExisting=false"
behaviour that creates an account if an existing account with the same
key does not exist.

Resolves #3281
2017-12-19 15:45:13 -08:00
Jacob Hoffman-Andrews fdd854a7e5 Fix various WFE2 bugs. (#3292)
- Encode certificate as PEM.
- Use lowercase for field names.
- Use termsOfServiceAgreed instead of Agreement
- Use a different ToS URL for v2 that points at the v2 HTTPS port.

Resolves #3280
2017-12-19 13:13:29 -08:00
Daniel McCarney 6c2c5f814d
Adopt ACME-09 camelCase for WFE2. (#3282)
This PR updates the wfe2 to use the camelCase convention[0] from the
recently published ACME draft-09[1]. For the Boulder WFE2 that primarily
meant changing directory keys and updating the order "FinalizeURL" field
to be "Finalize".

[0] - 7bace61b89 
[1] - https://tools.ietf.org/html/draft-ietf-acme-acme-09
2017-12-15 15:19:11 -05:00
Daniel McCarney edfb6b969f
Remove authorization combos for V2 API (#3278)
The `combinations` field of an authorization is a relic of the V1 API
and not present in the current ACME draft specifications. This commit
updates the WFE2's `prepAuthorizationForDisplay` function to remove the
`combinations` field before returning an authorization object to be
displayed in an API response.
2017-12-14 14:34:44 -05:00
Daniel McCarney b3d7665d4b
WFE2: Remove secondary ToS check. (#3274)
`terms-of-service-agreed` is checked at initial signup and doesn't need
to be rechecked. Worse, since the V2 registration only accepts a bool
the "Agreement" field is never set and checking it against != "" will
always fail for v2 accounts.

This was already done for Pebble[0] but was missed in the Boulder 
WFE2.

[0] - 6d6e811c1d
2017-12-14 13:58:01 -05:00
Daniel McCarney 09628bcfa2 WFE2 'new-nonce' endpoint (#3270)
This commit adds the "new-nonce" endpoint to the WFE2. A small unit test
is included. The existing /directory unit tests are updated for the new
endpoint.
2017-12-13 08:29:34 -08:00
Daniel McCarney a099e40b9c Add 'new-order' endpoint to WFE2 directory. (#3269)
When we implemented the new-order issuance flow for the WFE2 we forgot to include the endpoint in the /directory object. This commit adds it and updates associated tests.
2017-12-12 13:43:25 -08:00
Daniel McCarney 1c99f91733 Policy based issuance for wildcard identifiers (Round two) (#3252)
This PR implements issuance for wildcard names in the V2 order flow. By policy, pending authorizations for wildcard names only receive a DNS-01 challenge for the base domain. We do not re-use authorizations for the base domain that do not come from a previous wildcard issuance (e.g. a normal authorization for example.com turned valid by way of a DNS-01 challenge will not be reused for a *.example.com order).

The wildcard prefix is stripped off of the authorization identifier value in two places:

When presenting the authorization to the user - ACME forbids having a wildcard character in an authorization identifier.
When performing validation - We validate the base domain name without the *. prefix.
This PR is largely a rewrite/extension of #3231. Instead of using a pseudo-challenge-type (DNS-01-Wildcard) to indicate an authorization & identifier correspond to the base name of a wildcard order name we instead allow the identifier to take the wildcard order name with the *. prefix.
2017-12-04 12:18:10 -08:00
Daniel McCarney 2f263f8ed5 ACME v2 Finalize order support (#3169)
This PR implements order finalization for the ACME v2 API.

In broad strokes this means:

* Removing the CSR from order objects & the new-order flow
* Adding identifiers to the order object & new-order
* Providing a finalization URL as part of orders returned by new-order
* Adding support to the WFE's Order endpoint to receive finalization POST requests with a CSR
* Updating the RA to accept finalization requests and to ensure orders are fully validated before issuance can proceed
* Updating the SA to allow finding order authorizations & updating orders.
* Updating the CA to accept an Order ID to log when issuing a certificate corresponding to an order object

Resolves #3123
2017-11-01 12:39:44 -07:00
Jacob Hoffman-Andrews 97265c9184 Factor out context.go from wfe and wfe2. (#3086)
* Move probs.go to web.

* Move probs_test.go

* Factor out probs.go from wfe

* Move context.go

* Extract context.go into web package.

* Add a constructor for TopHandler.
2017-09-26 13:54:14 -04:00
Jacob Hoffman-Andrews 1b156822a1 Add verifyPOST and NewReg tests when GetRegByKey fails (#3062)
I thought there was a bug in NewRegistration when GetRegByKey returns an error, so I wrote a unittest... and discovered it works correctly. Oh well, now we have more tests!
2017-09-13 17:07:43 -07:00
Jacob Hoffman-Andrews 390b1c9d80 Remove Request-Id from logs. (#3072)
We originally planned to use this to match up logs across multiple systems, but we don't currently use it, and it chews up a lot of space in our logs. We can add it back in later if/when we want to start doing that correlation.
2017-09-12 09:25:18 -04:00
Jacob Hoffman-Andrews 568407e5b8 Remote VA logging and stats (#3063)
Add a logging statement that fires when a remote VA fail causes
overall failure. Also change remoteValidationFailures into a
counter that counts the same thing, instead of a histogram. Since
the histogram had the default bucket sizes, it failed to collect
what we needed, and produced more metrics than necessary.
2017-09-11 12:50:50 -07:00
Daniel McCarney d18e1dbcff Add WrongAuthorizationState error code for UpdateAuthorization (#3053)
This commit adds a new boulder error type WrongAuthorizationState.
This error type is returned by the SA when UpdateAuthorization is
provided an authz that isn't pending. The RA and WFE are updated
accordingly such that this error percolates back through the API to the
user as a Malformed problem with a sensible description. Previously this
behaviour resulted in a ServerInternal error.

Resolves #3032
2017-09-07 11:22:02 -07:00
Daniel McCarney baf32878c0 Prefix problem type with namespace at runtime. (#3039)
To support having problem types that use either the classic
"urn:acme:error" namespace or the new "urn:ietf:params:acme:error"
namespace as appropriate we need to prefix the problem type at runtime
right before returning it through the WFE to the user as JSON. This
commit updates the WFE/WFE2 to do this for both problems sent through
sendError as well as problems embedded in challenges. For the latter
we do not modify problems with a type that is already prefixed to
support backwards compatibility.

Resolves #2938

Note: We should cut a follow-up issue to devise a way to share some
common code between the WFE and WFE2. For example, the
prepChallengeForDisplay should probably be hoisted to a common
"web" package
2017-09-06 12:55:10 -07:00
Roland Bracewell Shoemaker 191a043585 Implement handler for retrieving an order object and SA RPC (#3016)
Fixes #2984 and fixes #2985.
2017-09-01 15:26:36 -07:00
Daniel 38b1c2620c
Merge remote-tracking branch 'le/master' into cpu-wfe2-revocation 2017-08-31 16:07:43 -04:00
Daniel 65f64a92ba
Remove deprecated `Resource` fields. 2017-08-30 12:28:15 -04:00
Daniel McCarney d9b0f98f75 Use "account" not "registration" throughout WFE2. (#3008)
The ACME specification no longer describes "registrations" since this is
a fairly overloaded term. Instead the term used is "account". This
commit updates the WFE2 & tests throughout to replace occurrences of
"reg" and "registration" to use "acct" and "account".

NOTE: This change is strictly limited to the wfe2 package. E.g. the
RA/SA and many core objects still refer to registrations.

Resolves #2986
2017-08-25 12:31:32 -07:00
Daniel b8916f176c
WFE2: Add Revocation support.
This commit implements certificate revocation for the WFE2. This
endpoint differs from others in that it supports *both* traditional key
ID based JWS request authentication in addition to embedded JWK based
JWS request authentication. The first is considered authenticated to
revoke a certificate if the signer account has valid authorizations for
all of the names in the certificate. The second is considered
authenticated if the embedded JWK that signs the request has the same
public key as the certificate being revoked.
2017-08-24 15:07:08 -04:00
Daniel McCarney d878510768 Migrate WFE2 to use Prometheus stats. (#3002)
Per #3001 we should not be adding new StatsD code for metrics anymore.
This commit updates all of the WFE2 to use 1st class Prometheus stats.
Unit tests are updated accordingly.

I have broken the error stats into two counts:

1. httpErrorCount for all of the http layer client request errors (e.g.
   no POST body, no content-length)
2. joseErrorCount, for all of the JOSE layer client request errors (e.g.
   malformed JWS, broken signature, invalid JWK)

This commit also removes the stubbed out `TestValidKeyRollover` function
from `wfe2/verify_test.go`. This was committed accidentally and the same
functionality is covered by the `wfe2/wfe_test.go` `TestKeyRollover`
function.
2017-08-23 15:05:41 -04:00