Commit Graph

4747 Commits

Author SHA1 Message Date
Daniel McCarney bb005e1c79
integration: add test for boulder-janitor. (#4364) 2019-07-29 16:13:10 -04:00
Jacob Hoffman-Andrews 98677b83d8 integration: make test case filter better (#4366) 2019-07-29 09:00:02 -07:00
Jacob Hoffman-Andrews a68c39ad9b SA: Delete unused challenges (#4353)
For authzv1, this actually executes a SQL DELETE for the unused challenges
when an authorization is updated upon validation.

For authzv2, this doesn't perform a delete, but changes the authorizations that
are returned so they don't include unused challenges.

In order to test the flag for both authz storage models, I set the feature flag in
both config/ and config-next/.

Fixes #4352
2019-07-26 14:04:46 -04:00
Roland Bracewell Shoemaker 59ef95230d integration: Fix typo in test/helpers.py (#4369) 2019-07-26 14:02:52 -04:00
Roland Bracewell Shoemaker 52dd3bd9c7 web: Log subproblems in RequestEvent (#4363) 2019-07-26 14:02:18 -04:00
Jacob Hoffman-Andrews 1613082c22 integration: Stop printing an exception for HTTP timeout test. (#4368) 2019-07-26 10:03:53 -04:00
Jacob Hoffman-Andrews ba5a5a5ac9 cmd: Log less from gRPC, no INFO level. (#4367)
The gRPC INFO log lines clutter up integration test output, and we've never
had a use for them in production (they are mostly about details of
connection status).
2019-07-26 10:02:34 -04:00
Roland Bracewell Shoemaker c7debd51b9
Set namespace for sub-problems (#4361)
Fixes #4355.
2019-07-25 10:26:58 -07:00
Daniel McCarney 9e896325f7
boulder-janitor: add initial daemon for tidying certificate resources. (#4354)
A new `boulder-janitor` command is added that provides a long-running
daemon that cleans up rows associated with expired certificate
resources. At present this is rows from the following tables:

* certificates
* certificateStatus
* certificatesPerName

Adding cleanup of tables associated with Order resources is the next step.

Three prometheus stats are exported:

* janitor_deletions - CounterVec for the number of deletions by table the 
  boulder-janitor has performed.
* janitor_workbatch - GaugeVec for the number of items of work by table
  the boulder-janitor queued for deletion.
* janitor_errors - CounterVec for the number of errors by table and error
  type the boulder-janitor has experienced.
2019-07-24 15:09:04 -04:00
Roland Bracewell Shoemaker cc2754cc57 Report the correct identifier when there are suberrors (#4358)
Turns out the test was already flagging this issue.

Fixes #4356.
2019-07-24 09:12:48 -07:00
Jacob Hoffman-Andrews 88992e3f0d sa: remove unused revokeAuthorizations functions. (#4351) 2019-07-22 13:51:19 -04:00
Jacob Hoffman-Andrews 4628c79239
Check invalid authorization limit in parallel. (#4348)
Fixes #3069.
2019-07-19 13:37:12 -07:00
Jacob Hoffman-Andrews 979e00651b sa: fix GetOrderForNames query ORDER BY to match comment. (#4349)
In #4331 I introduced this new more efficient query for
GetOrderForNames, and commented about why we needed an ORDER BY... ASC
to efficiently use the index. However, the actually query did not match
the comment, and it used DESC. This fixes the query.

To demonstrate that the index is actually used with the ASC version,
here's the EXPLAIN output after filling up the table with a bunch of
failed orders:

MariaDB [boulder_sa_integration]> explain select orderID, registrationID FROM orderFqdnSets
    -> WHERE setHash = UNHEX('B60FE34E4A6735D5A575D81C97F4DFED2102DC179B34252E4AA18F6E2A375C98')
    -> AND expires > NOW() ORDER BY EXPIRES ASC LIMIT 1 \G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: orderFqdnSets
         type: range
possible_keys: setHash_expires_idx
          key: setHash_expires_idx
      key_len: 37
          ref: NULL
         rows: 1500
        Extra: Using index condition
1 row in set (0.000 sec)

MariaDB [boulder_sa_integration]> explain select orderID, registrationID FROM orderFqdnSets
    -> WHERE setHash = UNHEX('B60FE34E4A6735D5A575D81C97F4DFED2102DC179B34252E4AA18F6E2A375C98')
    -> AND expires > NOW() ORDER BY EXPIRES DESC LIMIT 1 \G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: orderFqdnSets
         type: range
possible_keys: setHash_expires_idx
          key: setHash_expires_idx
      key_len: 37
          ref: NULL
         rows: 1500
        Extra: Using where
1 row in set (0.000 sec)
2019-07-18 15:24:47 -04:00
Jacob Hoffman-Andrews 5952d89346 wfe: add feature flag to control new acme v1 registrations. (#4346)
Adds `AllowV1Registration` feature flag to the WFE to control new acme v1 registrations.

Fixes #4306.
2019-07-18 15:18:05 -04:00
Jacob Hoffman-Andrews f06e0ac0b1 tests: delete old files that are no longer used. (#4347) 2019-07-18 14:21:29 -04:00
Jacob Hoffman-Andrews d077d3346e wfe/wfe2: remove AllowAuthzDeactivation flag. (#4345)
Fixes #4339
2019-07-17 16:30:27 -04:00
Daniel McCarney 028822d435 sa: drop SCTReceipts table and assoc. code. (#4344)
The `SCTReceipts` database table and associated model linkages are
legacy cruft from before Boulder implemented SCT embedding. We can
safely remove all of this stuff.
2019-07-17 11:12:42 -07: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
Jacob Hoffman-Andrews d41282dc3f wfe: use HandleFunc to separately process authzv2s. (#4334)
Previously we made v2 authz handling part of regular authz handling, and
just tried to strip the v2/ prefix. This led to a bug: #4327, where
authzv1s that had an id randomly start with "v2" would 404 because they
were treated as authzv2's.

This change moves authz2's and related challenges onto their own prefix,
and uses HandleFunc to dispatch them appropriately. To reduce code
duplication, I factored out the code that was common to v1 and v2 into
new Common functions.

I also changed the path names to contain "v3" instead of "v2" to avoid
potential confusion.
2019-07-16 09:54:05 -04:00
Daniel McCarney bdc9e17afe test: remove stale comment in sa_db_users.sql (#4335)
I noticed this stale bit of text in `test/sa_db_users.sql` while working on something unrelated.

The CA component does not have its own DB, it relies on the SA and its DB the same as
other components. Consulting a historian tells me that this was once true in a lost age :-)

The explicit license header comment isn't required. We don't follow this practice in any of
the other files and assume the base repo LICENSE file is sufficient.

Similarly we don't need to drop each user and recreate them, we use
`CREATE USER IF NOT EXISTS` from MariaDB 10.1+ We also don't need the related
`drop_users.sql` script.
2019-07-15 08:35:26 -07:00
Daniel McCarney f5a322006d SA: fix dangling getAllOrderAuthorizationStatuses tx. (#4336)
In the case where the DB `Select()` returns a non-nil `err` result the
SA's `getAllOrderAuthorizationStatuses` function needs to ensure it
rolls back the transaction it opened or it will be leaked.
2019-07-15 07:31:35 -07:00
Jacob Hoffman-Andrews 34a55a9b97 integration: add test for failed validation limit. (#4333)
I introduced test_fail_thrice as a specific regression test for #4329,
but I realized that a more general test of the failed validation limit
would have better coverage and also serve as a regression test at the
same time.

Fixes #4332.
2019-07-11 15:35:35 -04:00
Jacob Hoffman-Andrews 74699486ec Fix FasterGetOrderForNames and add tests. (#4331)
This rolls forward #4326 after it was reverted in #4328.

Resolves https://github.com/letsencrypt/boulder/issues/4329

The older query didn't have a `LIMIT 1` so it was returning multiple results,
but gorp's `SelectOne` was okay with multiple results when the selection was
going into an `int64`. When I changed this to a `struct` in #4326, gorp started
producing errors.

For this bug to manifest, an account needs to create an order, then fail
validation, twice in a row for a given domain name, then create an order once
more for the same domain name - that third request will fail because there are
multiple orders in the orderFqdnSets table for that domain.

Note that the bug condition doesn't happen when an account does three successful
issuances in a row, because finalizing an order (that is, issuing a certificate
for it) deletes the row in orderFqdnSets. Failing an authorization does not
delete the row in orderFqdnSets. I believe this was an intentional design
decision because an authorization can participate in many orders, and those
orders can have many other authorizations, so computing the updated state of
all those orders would be expensive (remember, order state is not persisted in
the DB but is calculated dynamically based on the authorizations it contains).

This wasn't detected in integration tests because we don't have any tests that
fail validation for the same domain multiple times. I filed an issue for an
integration test that would have incidentally caught this:
https://github.com/letsencrypt/boulder/issues/4332. There's also a more specific
test case in #4331.
2019-07-11 13:43:42 -04:00
alexzorin df2909a7ca va: Send extValue in TLSALPN unauthorized response (#4330)
Brings it to be more in line with the responses from the other two challenges and
will hopefully make the challenge a lot easier to debug (like in the recent community 
thread).

```json
"error": {
  "type": "urn:ietf:params:acme:error:unauthorized",
  "detail": "Incorrect validation certificate for tls-alpn-01 challenge. Expected acmeValidationV1 extension value 836bf5358f8a32826c61faeff2e0225b00756f935b00ed3002cabb9d536b9f53 for this challenge but got 8539b12e31c306b81a0aedab4128722c6ad71f71f46316a3c71612f47df0e532",
  "status": 403
},
```
2019-07-11 09:08:14 -07:00
Jacob Hoffman-Andrews 2131065b2d
Revert "SA: improve performance of GetOrderForNames. (#4326)" (#4328)
This reverts commit 9fa360769e.

This commit can cause "gorp: multiple rows returned for: ..." under certain situations.

See #4329 for details of followup.
2019-07-09 14:33:28 -07:00
Jacob Hoffman-Andrews 9fa360769e SA: improve performance of GetOrderForNames. (#4326)
When there are a lot of potential orders to reuse, the query could scan
unnecessary rows, sometimes leading to timeouts. The new query used 
when the FasterGetOrderForNames feature flag is enabled uses the
available index more effectively and adds a LIMIT clause.
2019-07-09 09:46:06 -04:00
Jacob Hoffman-Andrews e3f797f9dc grpc: Add better error message for timeouts. (#4324)
Right now we sometimes get errors like:

rpc error: code = Unknown desc = rpc error:
  code = DeadlineExceeded desc = context deadline exceeded

For instance, when an SA call times out, and the RA returns that
timed-out error to the WFE. These are kind of confusing because they
have two layers of nested gRPC error, and they don't provide additional
information about which SA call timed out.

This change replaces DeadlineExceeded errors with our own error type
that includes the service and the method that were called, as well as
the amount of time it took (which helps understand if timeouts are
happening because earlier calls ate up time towards the deadline).

When the RA->SA NewOrder call times out, and the RA returns that error to WFE:

"InternalErrors":["rpc error: code = Unknown desc =
  sa.StorageAuthority.NewOrder timed out after 14954 ms"]

When the WFE->RA NewOrder call times out:

"InternalErrors":["ra.RegistrationAuthority.NewOrder timed out after 15000 ms"]

Note that this change only handles timeouts at one level deep, which I
think is sufficient for our needs.
2019-07-08 13:47:25 -04:00
Roland Bracewell Shoemaker 3ea77270e3
Use primary key as cursor in cert-checker rather than serial (#4316)
`cert-checker` assumes an undefined behavior of MySQL which is only sometimes true, which means sometimes we select fewer certificates than we actually expect to. Instead of adding an explicit ORDER BY we simply switch to cursoring using the primary key, which gets us overall much more efficient usage of indexes.

Fixes #4315.
2019-07-03 12:05:48 -07:00
Jacob Hoffman-Andrews 3af49a16be
Revert "integration: move to Python3 (#4313)" (#4323)
This reverts commit 796a7aa2f4.

People's tests have been breaking on `docker-compose up` with the following output:

```
ImportError: No module named requests
```

Fixes #4322
2019-07-03 11:35:45 -07:00
Roland Bracewell Shoemaker 0d9b48e280 PA: restructure error for single bad name in multi-name req (#4319) 2019-07-03 13:47:31 -04:00
Jacob Hoffman-Andrews c8dbbf005d Handle unprintable characters in HTTP responses. (#4312)
Fixes #4244.
2019-07-02 13:42:55 -04:00
Daniel McCarney c7344170df
mod: update github.com/weppos/publicsuffix-go. (#4320)
Update `github.com/weppos/publicsuffix-go` to 5363748, the tip of master
at the time of writing.
2019-07-02 13:37:03 -04:00
Roland Bracewell Shoemaker cba4adac68 SA: Remove CountCertificatesByExactNames RPC (#4318) 2019-07-02 09:30:44 -04:00
Jacob Hoffman-Andrews 796a7aa2f4 integration: move to Python3 (#4313)
* integration: move to Python3

- Add parentheses to all print and raise calls.
- Python3 distinguishes bytes from strings. Add encode() and
  decode() calls as needed to provide the correct type.
- Use requests library consistently (urllib3 is not in Python3).
- Remove shebang from Python files without a main, and update
  shebang for integration-test.py.
2019-07-02 09:28:49 -04:00
Brad Warren d2afcd68ca Update Docker requirements (#4317)
According to https://docs.docker.com/compose/compose-file/#compose-and-docker-compatibility-matrix,
Docker Engine 1.13.0+ and Docker Compose 1.10.0+ are needed for Docker Compose
files using version 3.
2019-07-01 18:05:24 -07:00
Daniel McCarney 8a94ce053f
cert-checker: treat info/warning lint results as errs. (#4314) 2019-07-01 12:50:38 -04: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
Jacob Hoffman-Andrews 9094862051 ra/sa: clean up CountCertificatesExact. (#4309)
In #4179 we added a different method of counting the certificatesPerName
rate limit that can provide the correct behavior for exact public suffix
matches without the need for a separate RPC call. This cleans up the
separate code paths in the SA and RA that are no longer necesary.
2019-06-28 12:57:14 -04:00
Daniel McCarney 2d1a0d8e48
ra/pa: fix suberrors for single error case. (#4305)
If there is only one overall error then there is no reason to include it
as a sub-error, just return a top level error without any sub-errors.
2019-06-27 13:22:38 -04:00
Roland Bracewell Shoemaker 66f4a48b1b nonce-service: switch to proto3 (#4304) 2019-06-27 10:07:17 -04:00
Roland Bracewell Shoemaker 14d34e9075
Update square/go-jose to v2.3.1 (#4299)
Also excises the existing bad padding metrics code, adds a special error for when we encounter badly padded keys, and adds a test for the new special error.

Fixes #4070 and fixes #3964.
2019-06-26 16:27:50 -07:00
Roland Bracewell Shoemaker 1c8cfb3cba Fix SAN to CN promotion (#4298)
Before #4275 if a CSR only contained SANs longer than the max CN limit
it would set the CN to one anyway and would cause the 'CN too long'
check to get triggered. After #4275 if all of the SANs were too long
the CN wouldn't get set and we didn't have a check for `forceCNFromSAN
&& cn == ""` which would allow empty CNs despite `forceCNFromSAN`
being set. This adds that check and a test for the corner case.
2019-06-26 15:34:47 -07:00
Roland Bracewell Shoemaker 844ae26b65
Allow forwarding of nonce-service Redeem RPCs from one service… (#4297)
Fixes #4295.
2019-06-26 13:04:31 -07:00
Roland Bracewell Shoemaker 352899ba2f Remove RevokeAuthorizationsByDomain/2 functionality (#4302)
* Remove RevokeAuthorizationsByDomain/2 functionality
* Remove old integration test
2019-06-26 15:48:18 -04:00
Roland Bracewell Shoemaker d9e5cef182 SA: remove unnecessary CONVERT in authz2 JOIN (#4294)
This is a holdover from one of the tables (I think orderToAuthz2?) used a string
authorization ID and we needed to convert in order to get what we wanted but
apparently I never cleaned it up when we switched to integers for both tables.
What is really confusing here is why we ever needed a CONVERT in the first place
if Maria is happy to arbitrarily compare strings to integers itself... what fun.
2019-06-26 12:09:35 -04:00
Roland Bracewell Shoemaker c561386fd7
Explicitly disable authz2 orders (#4289)
Add flag to explicitly disable orders containing authz2 authorizations. After looking at a handful of much more complex solutions this feels like the best option. With NewAuthorizationSchema disabled and DisableAuthz2Orders enabled any requests for orders that include authz2 authorizations will return a 404 (where previously they would return a 500).

Fixes #4263.
2019-06-25 17:16:00 -07:00
Roland Bracewell Shoemaker a1540bd5ec web: log 200 if code not explicitly set (#4296) 2019-06-25 16:59:30 -04:00
Daniel McCarney 7f01d1274e
wfe2: consistently prep account resources for display. (#4293) 2019-06-25 14:26:25 -04:00
Jacob Hoffman-Andrews 38ef76bcba
Refactor test_caa into four test cases. (#4290)
The three new cases separately test:
 - Rechecking CAA during authz reuse.
 - Successful issuance for a positive CAA record
 - Rejected issuance for a negative CAA record
 - The various CAA extensions from https://tools.ietf.org/html/draft-ietf-acme-caa-06

Importantly, this also switches `recheck.good-caa-reserved.com` to use a
dynamically generated random name. This should fix the problem where
running integration tests locally several times resulted in hitting an
exact match rate limit error, requiring a clear of the fqdnSets table.

This also moves the creation of the client for test_recheck_caa into its
own early-setup function, so there is less test-case-specific setup in
integration-test.py.
2019-06-25 10:51:56 -07:00