Commit Graph

5076 Commits

Author SHA1 Message Date
Jacob Hoffman-Andrews cb06fe8e13
log: Remove trailing newlines and escape internal newlines. (#4925)
Fixes #4914.
2020-07-06 14:17:23 -07:00
Jacob Hoffman-Andrews df58af1406
Remove SA connection from ocsp-updater. (#4936)
The ocsp-updater no longer makes RPCs to the SA, but accesses the DB
directly (sometimes with help from SA functions to keep the DB
consistent).

This removes the SA connection config from config-next/. We'll remove
from config/ once the corresponding config has been removed from prod.
2020-07-06 14:14:02 -07:00
Aaron Gable 4a85abf25a
Fix error types emitted by good_key.go (#4932)
The `KeyPolicy.GoodKey` method is used to validate both public keys
used to sign JWK messages, and public keys contained inside CSR
messages.

According to RFC8555 section 6.7, validation failure in the former
case should result in `badPublicKey`, while validation failure in
the latter case should result in `badCSR`. In either case, a failure
due to reasons other than the key itself should result in
`serverInternal`.

However, the GoodKey method returns a variety of different errors
which are not all applicable depending on the context in which it is
called. In addition, the `csr.VerifyCSR` method passes these errors
through verbatim, resulting in ACME clients receiving confusing and
incorrect error message types.

This change causes the GoodKey method to always return either a
generic error or a KeyError. Calling methods should treat a `KeyError`
as either a `badPublicKey` or a `badCSR` depending on their context,
and may treat a generic error however they choose (though likely as a
serverInternal error).

Fixes #4930
2020-07-06 10:06:10 -07:00
Aaron Gable 35c19c2e08
Deprecate StoreKeyHashes flag (#4927)
The StoreKeyHashes feature flag controls whether rows are added to the
keyHashToSerial table. This feature is now enabled everywhere, so the
flag-protected code can be turned on unconditionally and the flag
removed from configs.

Related to #4895
2020-07-06 10:02:39 -07:00
Aaron Gable 71df093042
Make ocspchecker resilient to multiple errors (#4910)
Previously, if ocspchecker encountered a cert whose OCSP response
it didn't like, it would print the first reason it didn't like it and then
move on to the next cert provided on the command line. This
behavior both obscures the cert in question (by not printing
details of its OCSP response) and the error in question (by only
printing the first encountered error, instead of all errors).

This change causes ocspchecker to both print the details of the
OCSP response whether it likes the response or not, and to
accumulate all errors it encounters while validating that response.

This should increase interactive usability, as requested in #4901.
2020-07-02 16:23:58 -07:00
Aaron Gable eba3daa766
Update default value of ocspchecker -expectStatus (#4922)
This changes the default behavior of the `-expectStatus` flag of
the ocspchecker and ocsp_forever binaries (as well as any other
consumer of the ocsp/helper.go library).

Previously, the flag had a default value of 0, meaning that all
OCSP responses were expected to have a status of "Good" (i.e. not
"Revoked"); having any other status is an error which would cause
the tool to print different information and have a non-zero exit code.

This flag now has a default value of -1, meaning that no enforcement
of the OCSP status should happen. All OCSP responses, whether Good,
Revoked, or otherwise, will simply be logged for informational
purposes and the tool will exit successfully.

This is a backwards-incompatible change, and users which rely on
the default behavior of this flag should update themselves.
2020-07-02 16:16:12 -07:00
Aaron Gable f3db6d75ad
Remove key-hash-backfill cmd (#4928)
The key-hash-backfill cmd was used to fill the keyHashToSerial table
when it was first created. Now that the table is up and running, the
backfill utility can be removed.

Fixes #4895
2020-07-02 16:07:28 -07:00
Roland Bracewell Shoemaker aa79d8360d
Move FasterNewOrdersRateLimit feature flag to the right test/config-next file (#4929) 2020-07-02 14:03:38 -07:00
Jacob Hoffman-Andrews be2b19efee
Improve bad-key-revoker log output. (#4924)
Previously this was logging a map of emails to unrevokedCertificates.
Since unrevokedCertificates includes DER, which is a []byte, this was
getting printed as a series of decimal numbers, one for each byte.

This adds a Stringer implementation for unrevokedCertificates that
omits the DER.

Fixes #4921.
2020-07-02 10:09:26 -07:00
Roland Bracewell Shoemaker 1864325d87
cmd/ceremony: add delegated crl signer generation (#4913) 2020-07-02 08:44:45 -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
Jacob Hoffman-Andrews fe79f727a9
Restore SelectCertificateStatuses to SA. (#4902)
And use it in ocsp-updater. This was cleaned up in #4546 because it was
unused, but it should have been in use in ocsp-updater now that we can
make a straightforward query here instead of a JOIN.

This makes the SA the single source of truth for what columns are in the
certificateStatus table.
2020-07-01 12:20:29 -07:00
Jacob Hoffman-Andrews ca26126ca9
Replace master with main. (#4917)
Also, update an example username in mailer tests.
2020-06-30 16:39:39 -07:00
Roland Bracewell Shoemaker 054397b3cc
Add a github action to update master when push to main (#4916) 2020-06-29 18:20:21 -07:00
Aaron Gable afffbb899d
Add -expect-reason flag to checkocsp (#4901)
Adds a new -expect-reason flag to the checkocsp binary to allow for
verifying the revocation reason of the certificate(s) in question.
This flag has a default value of -1, meaning that no particular
revocation reason will be expected or enforced.

Also updates the -expect-status flag to have the same default (-1) and
behavior, so that when the tool is run interactively it can simply
print the revocation status of each certificate.

Finally, refactors the way the ocsp/helper library declares flags and
accesses their values. This unifies the interface and makes it easy to
extend to allow tests to modify parameters other than expectStatus when
desired.

Fixes #4885
2020-06-29 14:15:14 -07:00
Aaron Gable d16d3fd067
Remove OCSPStaleMaxAge config value and handling (#4911)
The OCSPStaleMaxAge config value was added in #2419 as part of an
effort to ensure that ocsp-updater's queries of the certificateStatus
table were efficient. It was never intended as a long-term fix:
in #2431 and #2432 the query was updated to index on the much more
efficient isExpired and notAfter columns if a feature flag was set,
and in #2561 that code path was made the default and the flag removed.

However, the `WHERE ocspLastUpdate > ocspStaleMaxAge` clause has
remained in the query. This is redundant, as the ocspStaleMaxAge has
always been set to 5040 hours, or 210 days, significantly longer than
the 90-day expiration of Let's Encrypt certs.

This change removes that clause from the query, and removes the config
scaffolding around it. In addition, it updates the tests to remove
workarounds necessitated by this column, and simplifies and documents
them for future readers.

Fixes #4884
2020-06-29 12:42:51 -07:00
Aaron Gable 2f0d52e46b
Update instructions for updating and testing dependencies (#4905)
Fixes #4896
2020-06-29 09:57:18 -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
Aaron Gable edee82d572
Remove unused wfe2 route constants (#4904)
The /acme/challenge and /acme/authz routes have no
associated handlers, and the challengePath and authzPath
constants have no code references.
2020-06-25 14:57:35 -07:00
Alexander Scheel a505ff80bb
Use GCD to check RSA moduli for small primes (#4883)
The existing checkSmallPrimes function maintains a table of primes,
converts them to an array of *big.Int and uses the resulting values
for comparing against a RSA modulus as follows:

    for _, prime := range smallPrimes {
        if modulus % prime != 0 {
            return invalid
        }
    }
    return valid

This incurs substantial overhead as each prime is checked individually,
invoking QuoRem(...) each time. By multiplying the primes together into
a single *big.Int, we can utilize a single library call, GCD(...), and
check all the values at once. While a single GCD invocation is slower
than a single QuoRem, 133 such invocations of QuoRem are together
slower than the single GCD.

BenchmarkSmallPrimeGCD
BenchmarkSmallPrimeGCD-4                       72759             16240 ns/op
BenchmarkSmallPrimeIndividualMods
BenchmarkSmallPrimeIndividualMods-4             8866            165265 ns/op

This gives us room to later increase the number of smallPrimes, if
desired, while keeping the same timing profile. Currently the product
of the 133 primes in smallPrimes fits within 1040 bits.

Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>
2020-06-24 13:05:47 -07:00
Aaron Gable e600b9e79f
Upgrade golang.org/x/text dependency to v0.3.3 (#4891)
This version contains
go.googlesource.com/text/+/23ae387dee1f90d29a23c0e87ee0b46038fbed0e
which fixes CVE-2020-14040. All tests pass at tag v0.3.3 in the upstream repo.

Fixes #4877.
2020-06-24 11:39:45 -07:00
Jacob Hoffman-Andrews dbc7be8217
Add Travis testing for `main` branch. (#4900) 2020-06-24 11:22:22 -07:00
Jacob Hoffman-Andrews a7bee6a7b8
Rename nonce-service stats for consistency. (#4894)
Now all stats start with "nonce_".
2020-06-23 16:08:48 -07:00
Jacob Hoffman-Andrews 5def886f19
Restore BlockedKeyTable to map of flag values. (#4893)
Without this, loading a config that has the BlockedKeyTable feature flag
will error out.
2020-06-23 16:07:32 -07:00
Jacob Hoffman-Andrews 36c8fed4d9
Fix up NoRows handling in bad-key-revoker. (#4874)
Join on the precertificates table to handle the case when a
precertificate was issued but no certificate.

Treat NoRows as a regular error.

Use named constants to specify revoked/expired arguments
to insertCert helper.

Remove the config gate on the bad-key-revoker unittest.
2020-06-23 11:31:21 -07:00
Jacob Hoffman-Andrews 7bddafd45e
Add MaxBytesReader for ocsp-responder. (#4869)
Also, return status code 500 when the OCSP response from
the DB is unparseable.
2020-06-23 11:30:59 -07:00
Roland Bracewell Shoemaker c4813cc340
cmd/ceremony: merge single-ocsp tool into ceremony (#4878)
Fixes #4658.
2020-06-23 11:30:31 -07:00
Aaron Gable c45d44b628
Format top-level markdown docs (#4890)
This change brings the three top-level markdown documents (README,
CONTRIBUTING, and CODE_OF_CONDUCT) in line with standard markdown
formatting and styling, as informed by
markdownlint/markdownlint:docs/RULES.md@master

Primarily, it:

Hard-wraps long lines to be 80 characters or less, except for
long URLs and code blocks;
Uniformly wraps all code blocks in triple-backticks, and supplies
language information for syntax highlighting; and
Makes a few other small tweaks.
2020-06-23 10:55:26 -07:00
Aaron Gable 47499233bf
Remove duplicate _db-next migration files (#4889)
These files have already been moved to the _db directory,
so they no longer need to exist in _db-next.

Fixes #4888
2020-06-22 18:18:15 -07:00
Aaron Gable 91d4e235ad
Deprecate the BlockedKeyTable feature flag (#4881)
This commit consists of three classes of changes:
1) Changing various command main.go files to always behave as they
   would have when features.BlockedKeyTable was true. Also changing
   one test in the same manner.
2) Removing the BlockedKeyTable flag from configuration in config-next,
   because the flag is already live.
3) Moving the BlockedKeyTable flag to the "deprecated" section of
   features.go, and regenerating featureflag_strings.go.

A future change will remove the BlockedKeyTable flag (and other
similarly deprecated flags) from features.go entirely.

Fixes #4873
2020-06-22 16:35:37 -07:00
Jacob Hoffman-Andrews 7b93e00021
Fix pass-through of revoke reason in ocsp-updater. (#4880)
This ensures that updates to OCSP responses keep the same reason code
as when they were revoked.
2020-06-18 17:37:32 -07:00
Jacob Hoffman-Andrews d1fa9f9db8
Add more logging to bad-key-revoker. (#4871) 2020-06-15 16:24:44 -07:00
Roland Bracewell Shoemaker 356510aa54
cmd/bad-key-revoker: don't skip certificates where the account has no contacts (#4872) 2020-06-15 10:33:28 -07:00
Jacob Hoffman-Andrews 20031f9796
Update ceremony documentation. (#4867)
Replace issuer-path with issuer-certificate-path, and fix a typo.
2020-06-15 09:14:15 -07:00
Jacob Hoffman-Andrews 0b0917cea6
Revert "Remove StoreIssuerInfo flag in CA (#4850)" (#4868)
This reverts commit 6454513ded.

We actually need to wait 90 days to ensure the issuerID field of the
certificateStatus table is non-nil for all extant certificates.
2020-06-12 12:50:24 -07:00
Roland Bracewell Shoemaker 325bba3a6f
va: measure local validation latency separately (#4865) 2020-06-12 12:44:25 -07:00
Jacob Hoffman-Andrews 065cfd502f
Limit request body size. (#4866)
Normally we do this with a reverse proxy in front of Boulder, but it's
nice to have an additional layer of protection in case someone deploys
Boulder without a reverse proxy.

Fixes #4730.
2020-06-12 12:02:49 -07:00
Jacob Hoffman-Andrews 3d9c31580a
Remove StoreIssuerInfo flag in SA. (#4849)
Now that the migration has been applied, we can reference the issuerID
field unconditionally. Also remove the migration file. It had already
been copied to sa/_db/migrations, but not removed from _db-next.

Part of a multi-PR changeset removing the StoreIssuerInfo flag.
2020-06-12 11:45:04 -07:00
Roland Bracewell Shoemaker 7f3c0f61a3
cmd/single-ocsp: validate issuer/responder are valid to sign the response (#4855)
Fixes #4853
2020-06-11 17:11:29 -07:00
Jacob Hoffman-Andrews 0fcfbc3e16
Shorten final certificate issuance log line. (#4861)
Previously, we logged both the precertificate and the final certificate
when the final certificate was signed. However, we already log the
precertificate body at precertificate issuance time, and we can conect
the two log lines by serial, so this was making the final certificate
log line unnecessarily long.
2020-06-10 16:19:32 -07:00
Jacob Hoffman-Andrews 06ffb57221
Update go-gorp and run go mod tidy. (#4860)
gorp now uses go modules.

```
$ cd ~/go/src/github.com/go-gorp/gorp/
$ git checkout v3.0.1
$ go test ./...
ok      github.com/go-gorp/gorp/v3      0.002s
```
2020-06-10 16:18:37 -07:00
Jacob Hoffman-Andrews 485f1ee0ba
Add periodic timestamp logging. (#4858)
Fixes #4827
2020-06-10 11:24:37 -07:00
Jacob Hoffman-Andrews b1d6da7504
Upgrade mysql driver to 1.5.0. (#4859)
Test output:

```
$ cd go/src/github.com/go-sql-driver/mysql/
$ git checkout v1.5.0
...
$ go test ./...
ok      github.com/go-sql-driver/mysql  0.253s
```
2020-06-10 11:20:51 -07:00
Roland Bracewell Shoemaker d516537394
cmd/ocsp-responder: calculate key hash rather than relying on SKID (#4851)
Rather than just assuming the SKID is the key hash, calculate the
actual hash, also reject any requests for hashes we don't support.
2020-06-09 17:56:34 -07:00
Roland Bracewell Shoemaker b7ad70caff
sa: implement faster new orders rate limit (#4857)
Fixes #4840
2020-06-09 17:14:23 -07:00
Jacob Hoffman-Andrews 8f7a6eb8d2
Upgrade to zlint 2.1. (#4854) 2020-06-09 14:03:40 -07:00
Jacob Hoffman-Andrews bf9b3da36d
Fix flag description for single-ocsp. (#4856)
The flag incorrectly claimed the -responder flag needed a DER
certificate but it actually needs a PEM certificate.
2020-06-09 13:49:04 -07:00
Jacob Hoffman-Andrews 6454513ded
Remove StoreIssuerInfo flag in CA (#4850)
As part of that, add support for issuer IDs in orphan-finder's
and RA's calls to GenerateOCSP.

This factors out the idForIssuer logic from ca/ca.go into a new
issuercerts package.

orphan-finder refactors:

Add a list of issuers in config.

Create an orphanFinder struct to hold relevant fields, including the
newly added issuers field.

Factor out a storeDER function to reduce duplication between the
parse-der and parse-ca-log cases.

Use test certificates generated specifically for orphan-finder tests.
This was necessary because the issuers of these test certificates have
to be configured for the orphan finder.
2020-06-09 12:25:13 -07:00
Jacob Hoffman-Andrews d003ae8116
ocspcheck: verify validity period of signing certificate (#4852) 2020-06-08 13:56:35 -07:00
Roland Bracewell Shoemaker 56898e8953
Log RSA key sizes in WFE/WFE2 and add feature to restrict them (#4839)
Currently 99.99% of RSA keys we see in certificates at Let's Encrypt are
either 2048, 3072, or 4096 bits, but we support every 8 bit increment
between 2048 and 4096. Supporting these uncommon key sizes opens us up to
having to block much larger ranges of keys when dealing with something
like the Debian weak keys incident. Instead we should just reduce the
set of key sizes we support down to what people actually use.

Fixes #4835.
2020-06-08 11:23:27 -07:00