Commit Graph

5115 Commits

Author SHA1 Message Date
Jacob Hoffman-Andrews ccec6cfa19
Move X509Signer from ceremony to pkcs11helpers. (#5004) 2020-07-31 13:24:37 -07:00
Aaron Gable 82e9e41597
Update CA RPC interface to proto3 (#4983) 2020-07-31 13:23:55 -07:00
Aaron Gable 46d7ed0a29
Anchor all referenced loop variables (#4991) 2020-07-29 12:57:30 -07:00
Jacob Hoffman-Andrews 0834ca4a19
pkcs11helper: add a Session abstraction (#4989) 2020-07-29 12:38:45 -07:00
milgradesec 09c060f3de
Update prometheus/client libs (#4993)
This pull requests updates prometheus/client_golang and
prometheus/client_model dependencies. Also updates
golang/protobuf as indirect.
2020-07-29 12:38:06 -07:00
Aaron Gable 09917baf47
Add gosec linter to golangci-lint (#4990)
This enables the gosec linter. It also disables a number of
warnings which it emits on the current codebase. Some of these
(e.g. G104: Errors unhandled) we expect to leave disabled
permanently; others (e.g. G601: Implicit memory aliasing in for loop)
we expect to fix and then enable to prevent regressions.

Part of #4948
2020-07-28 16:42:17 -07:00
Jacob Hoffman-Andrews 80d66f11b2
Simplify test for CRL signer. (#4987)
This mocks out the signer type rather than mocking out the pkcs11
object, making the test less dependent on the internals of our
pkcs11helpers package.

Part of refactorings related to #4918.
2020-07-28 13:28:03 -07:00
milgradesec 11d5ed4443
Update github.com/miekg/dns from v1.1.8 to v1.1.30 (#4984)
Includes 16 months of updates and security fixes.
2020-07-28 10:18:18 -07:00
Aaron Gable ffdae2d338
Return proto from ca.IssueCertificateFromPrecertificate (#4982)
This is the only method on the ca which uses a non-proto
type as its request or response value. Changing this to
use a proto removes the last logic from the wrappers,
allowing them to be removed in a future CL. It also makes
the interface more uniform and easier to reason about.

Issue: #4940
2020-07-23 18:39:10 -07:00
Jacob Hoffman-Andrews 62eae60711
Check for existing objects before generating a key. (#4981)
We only expect to want one key per slot/token.

Refactor key_test somewhat to split up cases, and add a new test case.
2020-07-23 16:55:43 -07:00
Aaron Gable 91ba1730dc
wfe: Return after sending errors (#4978)
Because these `wfe.sendError()` calls were not followed
by `return`s, the wfe was sending both them and the
next error encountered. In some cases, this could result
in the wrong HTTP response code being set, as that is
determined by the last error sent.
2020-07-23 12:11:59 -07:00
Jacob Hoffman-Andrews f9fd977bd6
Remove SerialExists. (#4976)
It no longer... exists.

Fixes #4943
2020-07-22 18:59:34 -07:00
Jacob Hoffman-Andrews 4ba537f293
Handle "too many objects" in pkcs11helper. (#4972)
Previously we were relying on a "more" boolean returned from
FindObjects. But according to
https://pkg.go.dev/github.com/miekg/pkcs11?tab=doc#Ctx.FindObjects,

> The returned boolean value is deprecated and should be ignored.

Instead, we ask for more objects than we need and error if we get more
than 1.

Add a test, and in the process split up the relevant test  into
multiple smaller test cases.
2020-07-22 18:57:28 -07:00
Aaron Gable 12d8674130
Move CA RPC non-nil checks out of wrappers (#4971)
Introduces a new generic helper utility to check that
fields of proto messages are non-nil and non-zero.

Uses this helper to simplify the ca RPC wrapper
methods, moving their completeness checks into
the underlying method handler. Also annotates the
completeness checks to justify which fields are or
are not being checked for future readers. Finally,
removes the similar non-nil checks from the client
wrappers, where they provide no marginal value.

Follow-up changes will do the same for other RPC
services, migrate said services to proto3, and change
the IssueCertificateForPrecertificate method to return
a corepb.Certificate instead of a core.Certificate, like
the other methods on the ca service.

Issues: #4955
2020-07-22 17:42:16 -07:00
Jacob Hoffman-Andrews 379aaeee4e
ceremony: Remove duplicated print of certificate PEM (#4974)
The same PEM bytes are already printed a few lines above,
on line 377.
2020-07-22 17:36:38 -07:00
Aaron Gable ffe71f967e
Update publicsuffix-go (#4975)
This brings in 14 commits, adds approximately 45
new public suffixes, and removes about 15:
983d101bec...2c0d957a74
2020-07-22 10:15:34 -07:00
Aaron Gable 3a03e86e89
Standardize all proto import names (#4970)
We previously used mixed case names for proto imports
(e.g. both `caPB` and `rapb`), sometimes in the same file.
This change standardizes on the all-lowercase spelling,
which was predominant throughout the codebase.
2020-07-20 16:29:17 -07:00
Jacob Hoffman-Andrews 7876120f9c
Increase granularity of new orders rate limit. (#4968)
Previously, this limit was bucketed by hour, but that created too much
sudden traffic at the beginning of each hour as accounts' rate limits
expired. Chunking by the minute should make it possible to smooth out
traffic more.
2020-07-20 14:58:34 -07:00
Jacob Hoffman-Andrews 0c543e7e2f
Move FasterNewOrdersRateLimit flag to config/ (#4969)
This flag is now live. Also move the migration from _db-next to _db.
2020-07-20 14:47:31 -07:00
Aaron Gable 8923fa29a7
Remove infinite memlock rlimit from docker config (#4967)
This was necessary to work around a poor interaction between
Go 1.4.x and unpatched linux kernels. Although we are still using
the same version of Go, and the Linux project only released the
fix in kernel 5.4.2 and later, Ubuntu has backported the fix into
Focal Fossa 20.04's 5.4.0 kernel. Therefore this workaround is
no longer needed.
https://github.com/golang/go/issues/37436#issuecomment-657436406

This also removes one need for elevated permissions, making it
easier to use docker rootless for development.
2020-07-20 14:12:45 -07:00
Aaron Gable 6f0016262f
Simplify database interactions (#4949)
Simplify database interactions

This change is a result of an audit of all places where
Go code directly constructs SQL queries and executes them
against a dbMap, with the goal of eliminating all instances
of constructing a well-known object type (such as a
core.CertificateStatus) from explicitly-listed database columns.
Instead, we should be relying on helper functions defined in the
sa itself to determine which columns are relevant for the
construction of any given object.

This audit did not find many places where this was occurring. It
did reveal a few simplifications, which are contained in this
change:
1) Greater use of existing SelectFoo methods provided by models.go
2) Streamlining of various SelectSingularFoo methods to always
   select by serial string, rather than user-provided WHERE clause
3) One spot (in ocsp-responder) where using a well-known type seemed
   better than using a more minimal custom type

Addresses #4899
2020-07-20 11:12:52 -07:00
Aaron Gable 7e626b63a6
Temporarily revert CA and VA proto3 migrations (#4962) 2020-07-16 14:29:42 -07:00
Aaron Gable 340d42760d
Break ceremony dependency on core (#4954) 2020-07-16 12:11:02 -07:00
Aaron Gable 281575433b
Switch VA RPCs to proto3 (#4960)
This updates va.proto to use proto3 syntax, and updates
all clients of the autogenerated code to use the new types. In
particular, it removes indirection from built-in types (proto3
uses ints, rather than pointers to ints, for example).

Fixes #4956
2020-07-16 09:16:23 -07:00
Aaron Gable 440c5f96d9
Remove unreferenced values from test configs (#4959) 2020-07-15 13:50:00 -07:00
Jacob Hoffman-Andrews 6fdc039c72
ceremony: Factor out openSigner (#4952)
We had some duplicated code related to opening the PKCS#11 session and
generating a signer, so I pulled it out into a separate function. This
function also takes an issuer so it can verify that the public key
matches what's expected.
2020-07-15 13:47:57 -07:00
Phil Porada 2afb087183
Add revocation reason metric to RA (#4957) 2020-07-15 13:30:15 -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
Aaron Gable 696fc4e122
Enable testing on go1.14.5 (#4953)
New go version 1.14.5 was released today:
https://groups.google.com/g/golang-announce/c/XZNfaiwgt2w/m/E6gHDs32AQAJ
It includes a security fix for X.509 verification
(CVE-2020-14039, https://golang.org/issue/39360).
2020-07-14 11:28:39 -07:00
Aaron Gable 24e782e8b4
Update CA RPC interface to proto3 (#4951)
This updates the ca.proto to use proto3 syntax, and updates
all clients of the autogenerated code to use the new types. In
particular, it removes indirection from built-in types (proto3
uses ints, rather than pointers to ints, for example).

It also updates a few instances where tests were being
conducted to see if various object fields were nil to instead
check for those fields' new zero-value.

Fixes #4940
2020-07-13 18:02:18 -07:00
Aaron Gable dea2f6ef92
Refactor and cleanup python integration tests (#4945) 2020-07-13 14:31:15 -07:00
Jacob Hoffman-Andrews 50d404333e
akamai-purger: empty queue on shutdown (#4944) 2020-07-10 13:04:46 -07:00
Jacob Hoffman-Andrews 8e64072d3b
Factor out common PKCS11 config types. (#4947)
Our PKCS11 config sections fall into two categories:
 - Those used for generating keys, where the HSM is both an input and an
   output, storing the resulting key in a specified slot.
 - Those used for signing certs, where the HSM is an input.

This creates dedicated config structs for these two, reducing
duplication in defining overall config structs. This also makes
defining test cases involving these config structs much more concise.

Fixes #4915
2020-07-10 11:31:37 -07:00
Jacob Hoffman-Andrews 3b5915a6f2
Reduce chance of log-validator having runaway output. (#4926) 2020-07-10 11:16:18 -07:00
Aaron Gable e906b9e272
Add test for re-signed OCSP revocation reasons (#4937) 2020-07-10 11:13:33 -07:00
orangepizza dee757c057
Remove multiva exception list code (#4933)
Fixes #4931
2020-07-08 10:57:17 -07:00
Roland Bracewell Shoemaker e940b6386f
ocsp: switch from cfssl/log to internal log (#4941)
Fixes #4898.
2020-07-08 09:32:23 -07:00
Roland Bracewell Shoemaker 0ad88e61f7
ca: remove SerialExists check in GenerateOCSP (#4942)
When StoreIssuerInfo is enabled the CA loses its ability to verify that the certificate we are requesting an OCSP response for is real directly (previously we sent the cert DER and checked the signature on it). In order to prevent the ocsp-updater from sending a request for a serial that doesn't exist we added a check that the serial we were being asked to generate a response for did actually exist. This introduced a significant amount of database pressure as it requires a DB query for every single OCSP response we generate. It also provides a minimal level of security, we already trust the ocsp-updater and creating a response for a certificate that doesn't exist doesn't actually accomplish much (if the ocsp-updater was compromised the more realistic attack would be asking to generate a good response for a revoked certificate).

This change removes the check that the serial exists from the CA.

Fixes #4935.
2020-07-07 18:40:11 -07:00
Roland Bracewell Shoemaker f8f4194c2a
cmd/ceremony: add CRL generation (#4892)
Also vendors the Go 1.15 CRL support for now, once we switch to 1.15
we can delete it.

Fixes #3714
2020-07-07 14:17:41 -07:00
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