Commit Graph

3921 Commits

Author SHA1 Message Date
Daniel McCarney f7bf82368a Return error from `sendHTTPRequest` immediately. (#2925)
Prior to this commit the `httpResp` result of `sendHTTPRequest` was
examined even in the case where `sendHTTPRequest` returns a non-nil
error. This can cause a nil panic since the `httpResp` may be `nil` when
the error is not. This commit returns an error from `Req()` immediately
when `sendHTTPRequest` returns one.
2017-07-31 11:19:03 -07:00
Jeff Hodges 221453d622 use go_import_path setting in Travis CI (#2923)
Travis has this setting available and so less code is needed in boulder's test
scripts.
2017-07-31 10:47:55 -07:00
Roland Bracewell Shoemaker 04394d1b76 Add newline when printing to STDERR (#2919)
In `log/log.go` when we fail to write to syslog we log the message to STDERR but without a newline. This causes all of the STDERR logs (when we reconnect to syslog) to be delivered where they go to be on a single line which causes some debugging pain.
2017-07-29 10:27:45 -07:00
Brian Smith 5f6d87a3a9 CA: Test that the CT poison extension in CSRs is ignored. (#2915) 2017-07-28 10:51:46 -07:00
Brian Smith 778d6ebcaa CA: Use a fresh CA object in each Invalid CSR subtest. (#2916)
Limit the interference between these subtests by giving each subtest its own CA
object, as is done for the other issuance tests.
2017-07-28 09:07:45 -07:00
Brian Smith 251ad45c24 CA: Refactor Must-Staple tests. (#2912)
Refactor must-staple tests to make them easier to adapt for precertificate-based
issuance.
2017-07-28 08:57:05 -07:00
Roland Bracewell Shoemaker 91e32bcf83 Fix unsafe rand.Rand usage in policy/pa.go (#2910)
After looking at this and thinking about it a bit more it doesn't really make sense to remove either usage of shuffling for the challenges or combinations. If we shuffle one but not the other we don't really get the behavior we want for either the v1 or v2 API (if the v2 API actually ends up using this and not it's own implementation) especially since there are people still developing new clients against the v1 API that we'd prefer aren't broken in the case we have to introduce another challenge for security reasons.

Instead I've just gone with the easy fix of implementing a lock around the usage. Another option would be to just create a new source each time and seed it using `rand.Int63` but I doubt that would be much faster than the latency the lock contention will introduce.

Fixes #2890.
2017-07-28 08:35:31 -04:00
Brian Smith b3c8bceae6 CA: Use unknown extension in "unsupported extension" test. (#2914)
The test previously used an invalid encoding of the CT poison extension
(the value was empty, but a valid CT poison extension has a NULL value).
In preparation for testing specifically how the CT poison extension is
handled, change the test to use a different extension instead.
2017-07-27 17:13:19 -07:00
Brian Smith 4f870fabb6 CA: Refactor certificate issuance profile selection tests. (#2913)
Split the profile issuance tests such that there is one call to IssueCertificate per test, like
the other certificate issuance tests. This will make it easier to later move the calls to
IssueCertificate() into TestIssueCertificate(), which will make it much easier to test the
precertificate-based flow in addition to the current issuance flow.
2017-07-27 17:11:46 -07:00
Jacob Hoffman-Andrews 3431acfb92 Adjust testing maxNames config to match prod. (#2911) 2017-07-27 15:23:29 -07:00
Daniel McCarney 538aeb4a43 WFEv2 updated JWS validation preparation (#2909)
This PR renames wfe2/jose.go to wfe2/verify.go to better reflect
its purpose.
Additionally this PR moves signatureValidationError, extractJWSKey
and verifyPOST from wfe2/wfe.go to wfe2/verify.go. This is in
preparation of refactoring for the ACME v2 POST verification logic to
help keep diffs reviewable.
2017-07-27 10:34:46 -07:00
Brian Smith 0b9dbfba33 CA: Prepare IssueCertificate() tests for being called multiple times. (#2903)
Take a step towards enabling the testing of precertificate issuance by
enabling the logic in these tests to be used for testing all forms
of Certificate and Precertificate issuance.
2017-07-26 16:24:46 -07:00
Roland Bracewell Shoemaker fcef38f78c Performance and cleanup database migration (#2882)
Switch certificates and certificateStatus to use autoincrement primary keys to avoid performance problems with clustered indexes (fixes #2754).

Remove empty externalCerts and identifierData tables (fixes #2881).

Make progress towards deleting unnecessary LockCol and subscriberApproved fields (#856,  #873) by making them NULLable and not including them in INSERTs and UPDATEs.
2017-07-26 15:18:28 -07:00
Jacob Hoffman-Andrews 8bc1db742c Improve recycling of pending authzs (#2896)
The existing ReusePendingAuthz implementation had some bugs:

It would recycle deactivated authorizations, which then couldn't be fulfilled. (#2840)
Since it was implemented in the SA, it wouldn't get called until after the RA checks the Pending Authorizations rate limit. Which means it wouldn't fulfill its intended purpose of making accounts less likely to get stuck in a Pending Authorizations limited state. (#2831)
This factors out the reuse functionality, which used to be inside an "if" statement in the SA. Now the SA has an explicit GetPendingAuthorization RPC, which gets called from the RA before calling NewPendingAuthorization. This happens to obsolete #2807, by putting the recycling logic for both valid and pending authorizations in the RA.
2017-07-26 14:00:30 -07:00
Daniel McCarney 57252c3b07 Remove letsencrypt/go-safe-browsing-api dependency. (#2905)
We have migrated from our fork of `go-safe-browsing-api` to Google's
safebrowsing v4 library. This commit removes the legacy safe browsing
code.
2017-07-26 13:57:57 -07:00
Daniel McCarney 2a84bc2495 Replace go-jose v1 with go-jose v2. (#2899)
This commit replaces the Boulder dependency on
gopkg.in/square/go-jose.v1 with gopkg.in/square/go-jose.v2. This is
necessary both to stay in front of bitrot and because the ACME v2 work
will require a feature from go-jose.v2 for JWS validation.

The largest part of this diff is cosmetic changes:

Changing import paths
jose.JsonWebKey -> jose.JSONWebKey
jose.JsonWebSignature -> jose.JSONWebSignature
jose.JoseHeader -> jose.Header
Some more significant changes were caused by updates in the API for
for creating new jose.Signer instances. Previously we constructed
these with jose.NewSigner(algorithm, key). Now these are created with
jose.NewSigner(jose.SigningKey{},jose.SignerOptions{}). At present all
signers specify EmbedJWK: true but this will likely change with
follow-up ACME V2 work.

Another change was the removal of the jose.LoadPrivateKey function
that the wfe tests relied on. The jose v2 API removed these functions,
moving them to a cmd's main package where we can't easily import them.
This function was reimplemented in the WFE's test code & updated to fail
fast rather than return errors.

Per CONTRIBUTING.md I have verified the go-jose.v2 tests at the imported
commit pass:

ok      gopkg.in/square/go-jose.v2      14.771s
ok      gopkg.in/square/go-jose.v2/cipher       0.025s
?       gopkg.in/square/go-jose.v2/jose-util    [no test files]
ok      gopkg.in/square/go-jose.v2/json 1.230s
ok      gopkg.in/square/go-jose.v2/jwt  0.073s

Resolves #2880
2017-07-26 10:55:14 -07:00
Jacob Hoffman-Andrews ef81f13f7b Remove "DONE" logging in unittest. (#2895)
This is not necessary because the framework prints a done message for us.
2017-07-25 13:37:58 -04:00
Jacob Hoffman-Andrews f8e9bf1144 Make SA and PA fields in CA unexported. (#2894)
An early design mistake meant that some fields of our services were exported
unnecessarily. In particular, fields storing handles of other services (e.g.
"SA" or "PA") were exported. This introduces the possibility of race conditions,
though in practice these fields are set at startup and never modified
concurrently.

We'd like to go through our codebase and change these all to unexported fields,
set at construction time. This is one step in that process.
2017-07-25 13:37:17 -04:00
Brian Smith ac63c78313 CA: Have IssueCertificate use IssueCertificateRequest directly. (#2886)
This is a step towards the long-term goal of eliminating wrappers and a step
towards the short-term goal of making it easier to refactor ca/ca_test.go to
add testing of precertificate-based issuance.
2017-07-25 13:35:25 -04:00
Roland Bracewell Shoemaker a656408630 Use standard SA methods in the expiration-mailer and refactor tests (#2893)
This makes making changes to the `certificate` and `certificateStatus` tables much easier in the future.
2017-07-24 15:24:33 -04:00
Roland Bracewell Shoemaker 7c6183b3b4 Fix debian weak key testing (#2884)
Initial implementation constructed the hash input incorrectly. New test uses a key modulus that is actually on the openssl weak key list instead of a random placeholder.
2017-07-20 12:25:32 -07:00
Roland Bracewell Shoemaker 05d869b005 Rename DNSResolver -> DNSClient (#2878)
Fixes #639.

This resolves something that has bugged me for two+ years, our DNSResolverImpl is not a DNS resolver, it is a DNS client. This change just makes that obvious.
2017-07-18 08:37:45 -04:00
Jeff Hodges b88750ede0 remove prefixdb and replace with mysql driver params (#2871)
This uses the mysql driver library's capability to use `SET` to set the system
variables that prefixdb previously was.

Unfortunately, the library doesn't sort the params when making the string, so we
have to do a little munging to TestNewDbMap.

Ran it in a checkout of the repo since godeps now doesn't include the test files (which is great!).

```
MYSQL_TEST_ADDR=127.0.0.1:3306 go test .
ok  	github.com/go-sql-driver/mysql	46.099s
```
2017-07-17 16:40:56 -07:00
Daniel McCarney f70e262935 Replace autoprom stats with Prometheus style stats. (#2869)
This commit replaces the existing expiration-mailer autoprom stats with
first-class Prometheus style stats.
2017-07-13 15:14:36 -07:00
Brian Smith 4fbcf86238 CA: Refactor invalid CSR tests into table-driven subtests. (#2868)
This will make it easier to add new tests of this form and will also
make it easier to adapt the tests to also test the precertificate +
certificate issuance flow.
2017-07-13 11:52:05 -07:00
Brian Smith a6e4f75da7 CA: Use Prometheus for CSR extension counters. (#2867)
Remove the use of mocks for stats in ca_test.go in order to make refactoring
those tests easier. To do so, switch to the same pattern used by the
signature metrics.
2017-07-13 10:19:19 -07:00
Daniel McCarney 2f53c202a6 Rename `validationTimeout`, document and clarify purpose. (#2866)
This commit renames the `validationTimeout` to `singleDialTimeout` and
adds a comment describing its purpose.
2017-07-12 11:35:14 -07:00
Daniel McCarney a268de2347 Update publicsuffix-go to e91dbc7. (#2864)
This commit updates the
`github.com/weppos/publicsuffix-go/publicsuffix` dependency to commit
e91dbc7, the tip of master at the time of writing.

Unit tests are confirmed to pass:
```
:~/go/src/github.com/weppos/publicsuffix-go$ go test ./...
?     github.com/weppos/publicsuffix-go/cmd/load  [no test files]
ok    github.com/weppos/publicsuffix-go/net/publicsuffix  0.006s
ok    github.com/weppos/publicsuffix-go/publicsuffix  0.025s

```
2017-07-12 14:34:49 -04:00
Jacob Hoffman-Andrews 63a25bf913 Remove clientName everywhere. (#2862)
This used to be used for AMQP queue names. Now that AMQP is gone, these consts
were only used when printing a version string at startup. This changes
VersionString to just use the name of the current program, and removes
`const clientName = ` from many of our main.go's.
2017-07-12 10:28:54 -07:00
Roland Bracewell Shoemaker 03dba10ca6 Rename contact-exporter to id-exporter (#2861)
* Change contact-exporter to id-exporter
2017-07-12 09:49:16 -04:00
Roland Bracewell Shoemaker 77f1364e9a Return more detailed error for connection reset in va (#2860)
If we hit a `syscall.ECONNRESET` error return a more useful error than `Error getting validation data`, updates the `TestDetailedError` test to cover this case.

Fixes #2851.
2017-07-11 14:29:31 -07:00
Jacob Hoffman-Andrews 9c7482fa94 Remove error return from Scope interface. (#2857)
This was inherited from the statsd interface but never used. This allows us to
remove one of our errcheck exceptions.
2017-07-11 10:54:06 -07:00
Daniel McCarney 957a68c72b Fix HTTP-01 IPv6 to IPv4 fallback with fresh dialer per conn. (#2852)
The implementation of the dialer used by the HTTP01 challenge, constructed with `resolveAndConstructDialer`, used the same wrapped `net.Dialer` for both the initial IPv6 connection, and any subsequent IPv4 fallback connections. This caused the IPv4 fallback to never succeed for cases where the initial IPv6 connection expended the `validationTimeout`.

This commit updates the http01Dialer (newly renamed from `dialer` since it is in fact specific to HTTP01 challenges) to use a fresh dialer for each connection. To facilitate testing the http01Dialer maintains
a count of how many dialer instances it has constructed. We use this in a unit test to ensure the correct behaviour without a great deal of new mocking/interfaces.

Resolves #2770
2017-07-10 15:41:49 -04:00
Daniel McCarney 9c01f8083e Update README for RAM requirement, add `cd` command. (#2849)
From... ahem... some frustrating debugging I determined that the Boulder
docker environment fails in strange & mysterious ways if you do not have
sufficient RAM. This commit adds this fact to the README to save future
souls my torment.

This commit also adds a cd to the intial git clone instructions to
ensure the user is in the correct directory to run docker-compose up
from.
2017-07-07 10:39:22 -07:00
Phil Porada 61b246000f Log when the boulder container connects to the database container (#2847)
Added a log message for when the boulder container can successfully talk to the database container
2017-07-07 11:31:05 -04:00
Daniel McCarney bd3e2747ba Duplicate WFE to WFE2. (#2839)
This PR is the initial duplication of the WFE to create a WFE2
package. The rationale is briefly explained in `wfe2/README.md`.

Per #2822 this PR only lays the groundwork for further customization
and deduplication. Presently both the WFE and WFE2 are identical except
for the following configuration differences:

* The WFE offers HTTP and HTTPS on 4000 and 4430 respectively, the WFE2
  offers HTTP on 4001 and 4431.
* The WFE has a debug port on 8000, the WFE2 uses the next free "8000
  range port" and puts its debug service on 8013

Resolves https://github.com/letsencrypt/boulder/issues/2822
2017-07-05 13:32:45 -07:00
Daniel McCarney 7120d72197 Improve error message for IPv6 failure with no IPv4 fallback. (#2844)
This commit improves the rather vague error message that was previously returned if an IPv6 challenge validation failed when IPv6First was enabled and there were no IPv4 addresses left to try as a fallback.

Resolves #2821
2017-07-05 15:54:30 -04:00
Daniel McCarney bbd0587440 Update acme-divergences documentation for draft-06 & draft-07 (#2845)
The IETF working group has published a [draft-06](https://tools.ietf.org/html/draft-ietf-acme-acme-07) and [draft-07 revision of ACME](https://tools.ietf.org/html/draft-ietf-acme-acme-07). This PR updates the Boulder `docs/acme-divergences.md` documentation for both drafts. Primarily this meant updating section numbers and links. 

Notable updates:
* Added "index" directory Link divergence
* Removed divergence for "existing" field of authorizations - this was removed from the spec so it isn't a divergence anymore \o/
* Added divergence for the Boulder certificates endpoint not respecting client `Accept` headers and using the `application/pkix-cert` content type in responses vs `application/pem-certificate-chain`
* Added divergence for `unsupportedContact` and `accountDoesNotExist` errors.
* Added divergence for the `only-return-existing` field.
* Added divergence for retrying challenges
* Removed "meta" directory divergence since Boulder supports this now

Resolves #2825
2017-07-05 12:24:12 -07:00
Jacob Hoffman-Andrews f710e574b3 Provide specific error for connection refused (#2843)
Fixes #2830.
2017-06-30 16:22:19 -07:00
Jacob Hoffman-Andrews 83272f47ca Chisel: use the requested challenge type. (#2842)
Previously, chisel had the DNS and HTTP challenge types switched.
2017-06-30 10:42:12 -04:00
Roland Bracewell Shoemaker 088b872287 Implement multi VA validation (#2802)
Adds basic multi-path validation functionality. A new method `performRemoteValidation` is added to `boulder-va` which is called if it is configured with a list of remote VA gRPC addresses. In this initial implementation the remote VAs are only used to check the validation result of the main VA, if all of the remote validations succeed but the local validation failed, the overall validation will still fail. Remote VAs use the exact same code as the local VA to perform validation. If the local validation succeeds then a configured quorum of the remote VA successes must be met in order to fully complete the validation.

This implementation assumes that metrics are collected from the remote VAs in order to have visibility into their individual validation latencies etc.

Fixes #2621.
2017-06-29 14:11:01 -07:00
Daniel McCarney 7cdab9c10d Ensure consistent ordering from getFQDNSetsBySerials. (#2838)
Fixes flaky getFQDNSetsBySerials unit test.
2017-06-29 13:52:58 -07:00
Roland Bracewell Shoemaker f5bc9e892a Update github.com/google/safebrowsing and block on database health (#2837)
Update github.com/google/safebrowsing and block on database health before starting VA 
before starting `boulder-va`.

```
$ go test .
ok  	github.com/google/safebrowsing	4.510s

$ go test .
ok  	github.com/golang/protobuf/ptypes	0.002s
```

Fixes #2742.
2017-06-28 09:44:58 -04:00
Daniel McCarney 71f8ae0e87 Improve renewal rate limiting (#2832)
As described in Boulder issue #2800 the implementation of the SA's
`countCertificates` function meant that the renewal exemption for the
Certificates Per Domain rate limit was difficult to work with. To
maximize allotted certificates clients were required to perform all new
issuances first, followed by the "free" renewals. This arrangement was
difficult to coordinate.

In this PR `countCertificates` is updated such that renewals are
excluded from the count reliably. To do so the SA takes the serials it
finds for a given domain from the issuedNames table and cross references
them with the FQDN sets it can find for the associated serials. With the
FQDN sets a second query is done to find all the non-renewal FQDN sets
for the serials, giving a count of the total non-renewal issuances to
use for rate limiting.

Resolves #2800
2017-06-27 15:39:59 -04:00
Roland Bracewell Shoemaker 4119bc7cde cmd/contact-exporter: allow filtering contacts by domains in certificates (#2833)
Provide functionality to cmd/contact-exporter to filter exported contacts by domains in certificates

Fixes #2795.
2017-06-26 15:40:47 -04:00
Jacob Hoffman-Andrews 5b9d737380 Fix statsd->prometheus bridge. (#2828)
In #2752, I accidentally introduced a change that would use a NewRegistry for
each NewPromScope, ignoring the Registry that was passed as an argument. Because
this registry was not attached to any HTTP server, the results would not get
exported. This fixes that, so the Registry passed into NewPromScope is
respected.

In the process, I noticed that stats were getting prefixed by a spurious "_". I
fixed that by turning prefix into a slice of strings, and combining them with "_"
only if it the slice is non-empty.

Fixes #2824.
2017-06-26 14:07:30 -04:00
Brad Warren ee2f88a2e4 Use Docker Compose version 2 format (#2834)
After talking to @jsha, this updates Boulder's docker-compose.yml to version 2. I'm currently working on moving some Certbot tests from EC2 to Docker and this allows me to take advantage of networking features like embedded DNS which is used by default in newer versions of Docker Compose.

This shouldn't change any behavior of the file. One notable thing is I had to add network_mode: bridge to the bhsm service. I don't believe this is a change in behavior though since bhsm was included in the links section for boulder
2017-06-26 10:29:47 -04:00
Roland Bracewell Shoemaker c5da184c97 Fix ReusePendingAuthz feature (#2827)
Fixes #2826.
2017-06-21 17:19:14 -07:00
Jacob Hoffman-Andrews 41df4ae10f Set ReusePendingAuthz in config-next. (#2820) 2017-06-21 09:44:57 -04:00
Daniel McCarney 5bb1ed8178 Update CONTRIBUTING.md for ACMEv2 plan. (#2816) 2017-06-19 15:48:00 -04:00