Commit Graph

3824 Commits

Author SHA1 Message Date
Jacob Hoffman-Andrews 4e30af4ec8 Collapse switch cases. 2017-05-31 14:17:55 -07:00
Jacob Hoffman-Andrews 81e58b66f7 Use whitelisted methods for HTTP stats.
Fixes #2776
2017-05-30 15:50:12 -07:00
Daniel McCarney f8022fb3f4 Updates CFSSL dep to c9a961e. (#2778)
Per review policy, running tests in updated dependencies yields:

```
$ go test ./vendor/github.com/cloudflare/cfssl/ocsp/
?       github.com/letsencrypt/boulder/vendor/github.com/cloudflare/cfssl/ocsp  [no test files]
```
2017-05-22 15:14:59 -07:00
Jacob Hoffman-Andrews f6afdd698d Clean up duplicated port management code (#2749)
The VA previously had a lot of repetitive code of the form:
```
	hs := httpSrv(t, expectedToken)
	defer hs.Close()
	port, err := getPort(hs)
	test.AssertNotError(t, err, "failed to get test server port")
	va, _, log := setup()
	va.httpPort = port
```

This PR moves the port management to the `setup()`  func and updates the tests accordingly.

Resolves https://github.com/letsencrypt/boulder/issues/2740
2017-05-18 12:59:49 -07:00
Daniel eab44959f3
Review feedback 2017-05-18 15:08:53 -04:00
Roland Bracewell Shoemaker e2aff429a7 Fix bug in relativeDirectory that skipped adding the random key (#2771)
Also adds test to check for the problem.
2017-05-17 16:06:28 -07:00
Roland Bracewell Shoemaker d28f9b877b Switch CT import path (#2769)
Switches imports from `github.com/google/certificate-transparency` to `github.com/google/certificate-transparency-go` and vendors the new code. Also fixes a number of small breakages caused by API changes since the last time we vendored the code. Also updates `github.com/cloudflare/cfssl` since you can't vendor both `github.com/google/certificate-transparency` and `github.com/google/certificate-transparency-go`.

Side note: while doing this `godep` tried to pull in a number of imports under the `golang.org/x/text` repo that I couldn't find actually being used anywhere so I just dropped the changes to `Godeps/Godeps.json` and didn't add the vendored dir to the tree, let's see if this breaks any tests...

All tests pass

```
$ go test ./...
ok  	github.com/google/certificate-transparency-go	0.640s
ok  	github.com/google/certificate-transparency-go/asn1	0.005s
ok  	github.com/google/certificate-transparency-go/client	22.054s
?   	github.com/google/certificate-transparency-go/client/ctclient	[no test files]
ok  	github.com/google/certificate-transparency-go/fixchain	0.133s
?   	github.com/google/certificate-transparency-go/fixchain/main	[no test files]
ok  	github.com/google/certificate-transparency-go/fixchain/ratelimiter	27.752s
ok  	github.com/google/certificate-transparency-go/gossip	0.322s
?   	github.com/google/certificate-transparency-go/gossip/main	[no test files]
ok  	github.com/google/certificate-transparency-go/jsonclient	25.701s
ok  	github.com/google/certificate-transparency-go/merkletree	0.006s
?   	github.com/google/certificate-transparency-go/preload	[no test files]
?   	github.com/google/certificate-transparency-go/preload/dumpscts/main	[no test files]
?   	github.com/google/certificate-transparency-go/preload/main	[no test files]
ok  	github.com/google/certificate-transparency-go/scanner	0.013s
?   	github.com/google/certificate-transparency-go/scanner/main	[no test files]
ok  	github.com/google/certificate-transparency-go/tls	0.033s
ok  	github.com/google/certificate-transparency-go/x509	1.071s
?   	github.com/google/certificate-transparency-go/x509/pkix	[no test files]
?   	github.com/google/certificate-transparency-go/x509util	[no test files]
```
```
$ ./test.sh
...
ok  	github.com/cloudflare/cfssl/api	1.089s	coverage: 81.1% of statements
ok  	github.com/cloudflare/cfssl/api/bundle	1.548s	coverage: 87.2% of statements
ok  	github.com/cloudflare/cfssl/api/certadd	13.681s	coverage: 86.8% of statements
ok  	github.com/cloudflare/cfssl/api/client	1.314s	coverage: 55.2% of statements
ok  	github.com/cloudflare/cfssl/api/crl	1.124s	coverage: 75.0% of statements
ok  	github.com/cloudflare/cfssl/api/gencrl	1.067s	coverage: 72.5% of statements
ok  	github.com/cloudflare/cfssl/api/generator	2.809s	coverage: 33.3% of statements
ok  	github.com/cloudflare/cfssl/api/info	1.112s	coverage: 84.1% of statements
ok  	github.com/cloudflare/cfssl/api/initca	1.059s	coverage: 90.5% of statements
ok  	github.com/cloudflare/cfssl/api/ocsp	1.178s	coverage: 93.8% of statements
ok  	github.com/cloudflare/cfssl/api/revoke	2.282s	coverage: 75.0% of statements
ok  	github.com/cloudflare/cfssl/api/scan	2.729s	coverage: 62.1% of statements
ok  	github.com/cloudflare/cfssl/api/sign	2.483s	coverage: 83.3% of statements
ok  	github.com/cloudflare/cfssl/api/signhandler	1.137s	coverage: 26.3% of statements
ok  	github.com/cloudflare/cfssl/auth	1.030s	coverage: 68.2% of statements
ok  	github.com/cloudflare/cfssl/bundler	15.014s	coverage: 85.1% of statements
ok  	github.com/cloudflare/cfssl/certdb/dbconf	1.042s	coverage: 78.9% of statements
ok  	github.com/cloudflare/cfssl/certdb/ocspstapling	1.919s	coverage: 69.2% of statements
ok  	github.com/cloudflare/cfssl/certdb/sql	1.265s	coverage: 65.7% of statements
ok  	github.com/cloudflare/cfssl/cli	1.050s	coverage: 61.9% of statements
ok  	github.com/cloudflare/cfssl/cli/bundle	1.023s	coverage: 0.0% of statements
ok  	github.com/cloudflare/cfssl/cli/crl	1.669s	coverage: 57.8% of statements
ok  	github.com/cloudflare/cfssl/cli/gencert	9.278s	coverage: 83.6% of statements
ok  	github.com/cloudflare/cfssl/cli/gencrl	1.310s	coverage: 73.3% of statements
ok  	github.com/cloudflare/cfssl/cli/genkey	3.028s	coverage: 70.0% of statements
ok  	github.com/cloudflare/cfssl/cli/ocsprefresh	1.106s	coverage: 64.3% of statements
ok  	github.com/cloudflare/cfssl/cli/revoke	1.081s	coverage: 88.2% of statements
ok  	github.com/cloudflare/cfssl/cli/scan	1.217s	coverage: 36.0% of statements
ok  	github.com/cloudflare/cfssl/cli/selfsign	2.201s	coverage: 73.2% of statements
ok  	github.com/cloudflare/cfssl/cli/serve	1.133s	coverage: 39.0% of statements
ok  	github.com/cloudflare/cfssl/cli/sign	1.210s	coverage: 54.8% of statements
ok  	github.com/cloudflare/cfssl/cli/version	2.475s	coverage: 100.0% of statements
ok  	github.com/cloudflare/cfssl/cmd/cfssl	1.082s	coverage: 0.0% of statements
ok  	github.com/cloudflare/cfssl/cmd/cfssljson	1.016s	coverage: 4.0% of statements
ok  	github.com/cloudflare/cfssl/cmd/mkbundle	1.024s	coverage: 0.0% of statements
ok  	github.com/cloudflare/cfssl/config	2.754s	coverage: 67.7% of statements
ok  	github.com/cloudflare/cfssl/crl	1.063s	coverage: 68.3% of statements
ok  	github.com/cloudflare/cfssl/csr	27.016s	coverage: 89.6% of statements
ok  	github.com/cloudflare/cfssl/errors	1.081s	coverage: 81.2% of statements
ok  	github.com/cloudflare/cfssl/helpers	1.217s	coverage: 80.4% of statements
ok  	github.com/cloudflare/cfssl/helpers/testsuite	7.658s	coverage: 65.8% of statements
ok  	github.com/cloudflare/cfssl/initca	205.809s	coverage: 74.2% of statements
ok  	github.com/cloudflare/cfssl/log	1.016s	coverage: 59.3% of statements
ok  	github.com/cloudflare/cfssl/multiroot/config	1.107s	coverage: 77.4% of statements
ok  	github.com/cloudflare/cfssl/ocsp	1.524s	coverage: 77.7% of statements
ok  	github.com/cloudflare/cfssl/revoke	1.775s	coverage: 79.6% of statements
ok  	github.com/cloudflare/cfssl/scan	1.022s	coverage: 1.1% of statements
ok  	github.com/cloudflare/cfssl/selfsign	1.119s	coverage: 70.0% of statements
ok  	github.com/cloudflare/cfssl/signer	1.019s	coverage: 20.0% of statements
ok  	github.com/cloudflare/cfssl/signer/local	3.146s	coverage: 81.2% of statements
ok  	github.com/cloudflare/cfssl/signer/remote	2.328s	coverage: 71.8% of statements
ok  	github.com/cloudflare/cfssl/signer/universal	2.280s	coverage: 67.7% of statements
ok  	github.com/cloudflare/cfssl/transport	1.028s
ok  	github.com/cloudflare/cfssl/transport/ca/localca	1.056s	coverage: 94.9% of statements
ok  	github.com/cloudflare/cfssl/transport/core	1.538s	coverage: 90.9% of statements
ok  	github.com/cloudflare/cfssl/transport/kp	1.054s	coverage: 37.1% of statements
ok  	github.com/cloudflare/cfssl/ubiquity	1.042s	coverage: 88.3% of statements
ok  	github.com/cloudflare/cfssl/whitelist	2.304s	coverage: 100.0% of statements
```

Fixes #2746.
2017-05-17 13:41:33 -07:00
Daniel 701cb5cb44
Merge master, review feedback. 2017-05-17 12:13:36 -04:00
Jacob Hoffman-Andrews 2d0734d35b Fix flakiness in VA test. (#2767)
When the VA validates a domain, it runs both CAA check and validation check in
parallel. If the validation check returns a failed result before the CAA check is done,
the VA returns immediately. However, the CAA check increments a stat. So there's
a flaky condition where, depending on the timing, that stat increment may or may
not get called on the MockScope. Add `.AnyTimes()` to our mock statements to
indicate we don't care whether Inc gets called.
2017-05-15 16:44:59 -07:00
Daniel McCarney e1bff721a7 Fixes master's unit tests, test failure. (#2763)
* Fixes post-merge artifact breaking VA unit tests.

* Fixes CI unit tests to fail build if tests fail.
2017-05-15 14:33:31 -04:00
Jacob Hoffman-Andrews b17b5c72a6 Remove statsd from Boulder (#2752)
This removes the config and code to output to statsd.

- Change `cmd.StatsAndLogging` to output a `Scope`, not a `Statter`.
- Remove the prefixing of component name (e.g. "VA") in front of stats; this was stripped by `autoProm` but now no longer needs to be.
- Delete vendored statsd client.
- Delete `MockStatter` (generated by gomock) and `mocks.Statter` (hand generated) in favor of mocking `metrics.Scope`, which is the interface we now use everywhere.
- Remove a few unused methods on `metrics.Scope`, and update its generated mock.
- Refactor `autoProm` and add `autoRegisterer`, which can be included in a `metrics.Scope`, avoiding global state. `autoProm` now registers everything with the `prometheus.Registerer` it is given.
- Change va_test.go's `setup()` to not return a stats object; instead the individual tests that care about stats override `va.stats` directly.

Fixes #2639, #2733.
2017-05-15 10:19:54 -04:00
Jacob Hoffman-Andrews 65f1242ed4 Adds "meta" entry w/ ToS to /directory. (#2745)
This commit adds the acme draft-02+ optional "meta" element for the
/directory response. Presently we only include the optional
"terms-of-service" URL. Whether the meta entry is included is controlled
by two factors:

  1. The state of the "DirectoryMeta" feature flag, which defaults to
     off
  2. Whether the client advertises the UA we know to be intolerant of
     new directory entries.

The TestDirectory unit test is updated to test both states of the flag
and the UA detection.
2017-05-12 16:21:38 -07:00
Daniel McCarney 7393db6d59 Fixes RPC bug for CountCertificatesExact feature flag. (#2759)
With the CountCertificatesExact feature flag enabled if the RA's
checkCertificatesPerNameLimit was called with names only containing
domains exactly matching a public suffix entry then the legacy
ra.enforceNameCounts function will be called with an empty tldNames
argument. This in turn will cause the RA->SA RPC to fail with an
"incomplete gRPC request message error".

This commit fixes this bug by only calling ra.enforceNameCounts when
len(tldNames) > 0.

Resolves #2758
2017-05-12 15:21:00 -04:00
Roland Bracewell Shoemaker bbe74927f8 Merge pull request #2756 from letsencrypt/cpu-makes-err-msg-mistake-is-sorry
Rewords IPv6 to IPv4 fallback message
2017-05-12 12:15:34 -07:00
Daniel 45837b0f71
Avoids double type assert 2017-05-12 14:50:27 -04:00
Daniel McCarney 1e57de2a00 Removes "coverage" from default RUN. (#2750)
Having "coverage" in the default RUN is leaving ".coverprofile" files
all over the src tree. This commit removes this task from the default
RUN list for local work. It is included in travis.yml and will still run
for CI or when specified explicitly with a command line env var
  override.
2017-05-11 10:38:22 -04:00
Daniel c905cfb8db
Rewords IPv6 -> IPv4 fallback error messages. 2017-05-11 10:35:30 -04:00
Daniel d0029fcc41
Cleans up duplicated port management code. 2017-05-10 10:50:02 -04:00
Roland Bracewell Shoemaker bd045b9325 Fix OCSP-Responder double slash collapsing (#2748)
Uses a special mux for the OCSP Responder so that we stop collapsing double slashes in GET requests which cause a small number of requests to be considered malformed.
2017-05-10 09:51:10 -04:00
Daniel 8c547473b8
Adds "meta" entry w/ ToS to /directory.
This commit adds the acme draft-02+ optional "meta" element for the
/directory response. Presently we only include the optional
"terms-of-service" URL. Whether the meta entry is included is controlled
by two factors:

  1. The state of the "DirectoryMeta" feature flag, which defaults to
     off
  2. Whether the client advertises the UA we know to be intolerant of
     new directory entries.

The TestDirectory unit test is updated to test both states of the flag
and the UA detection.
2017-05-09 15:43:16 -04:00
Daniel McCarney dfd0857e97 Removes outdated comment & unused errNotWhitelisted. (#2744) 2017-05-09 13:12:28 -04:00
Roland Bracewell Shoemaker 730318a755 Add GREASE to directory (#2731)
Randomly generates and adds a key to the directory object with the value grease.

Fixes #2415.
2017-05-08 14:13:35 -07:00
Daniel McCarney 47452d6c6c Prefer IPv6 addresses, fall back to IPv4. (#2715)
This PR introduces a new feature flag "IPv6First". 

When the "IPv6First" feature is enabled the VA's HTTP dialer and TLS SNI
(01 and 02) certificate fetch requests will attempt to automatically
retry when the initial connection was to IPv6 and there is an IPv4
address available to retry with.

This resolves https://github.com/letsencrypt/boulder/issues/2623
2017-05-08 13:00:16 -07:00
Daniel McCarney 101da45d04 Updates publicsuffix-go to 908fd3b. (#2727)
This commit updates the `publicsuffix-go` dependency to 908fd3b. Per
CONTRIBUTING.md the upstream unit tests were verified to pass:

```
daniel@XXXX:~/go/src/github.com/weppos/publicsuffix-go$ git log --oneline | head -n1
908fd3b autopull: 2017-04-25T06:00:35Z (#75)

daniel@XXXX:~/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.014s
ok    github.com/weppos/publicsuffix-go/publicsuffix  0.027s
```
2017-05-08 10:38:04 -07:00
Daniel McCarney 406f5768ff Merge pull request #2729 from letsencrypt/remove-old-err-checks
Remove core.XXXError type checks
2017-05-04 12:44:30 -04:00
Daniel McCarney b9369a4814 Uses `UniqueLowerNames` for domain/suffix rl funcs. (#2725)
Both `ra.domainsForRateLimiting` and `ra.suffixesForRateLimiting` were
doing their own "unique"ing with a `map[string]struct{}` when they could
have used `core.UniqueLowerNames`. This commit updates them both to do
so and adjusts the unit tests to expect the new sorted order return.
2017-05-04 12:37:05 +01:00
Daniel McCarney 361e7d4caa Clean up `berrors` (#2724)
This PR removes two berrors that aren't used anywhere in the codebase:

TooManyRequests , a holdover from AMQP, and is no longer used.
UnsupportedIdentifier, used just for rejecting IDNs, which we no longer do.
In addition, the SignatureValidation error was only used by the WFE so it is moved there and unexported.

Note for reviewers: To remove berrors.UnsupportedIdentifierError I replaced the errIDNNotSupported error in policy/pa.go with a berrors.MalformedError with the same name. This allows removing UnsupportedIdentifierError ahead of #2712 which removes the IDNASupport feature flag. This seemed OK to me, but I can restore UnsupportedIdentifierError and clean it up after 2712 if that's preferred.

Resolves #2709
2017-05-04 10:56:26 +01:00
Roland Bracewell Shoemaker 636a1fc878 Remove core.XXXError type checks 2017-05-03 22:18:13 +00:00
Daniel McCarney 40663ba66c Fixes test speeds by splitting `-race` from coverage runs. (#2721)
The unit test runs in CI have been taking ~20 minutes. The root cause is
using `-race` on every individual `go test` invocation. We can't switch
to one big `go test` with `-race` instead of individuals if we want test
coverage to be reported. The workaround is to do one big `go test` with
`-race` first, and then many individual `go test`'s to collect coverage
*without* `-race`. This is still faster overall than the current state
of affairs.

Resolves https://github.com/letsencrypt/boulder/issues/2695
2017-05-02 14:57:32 -07:00
Daniel McCarney 1ed34a4a5d Fixes cert count rate limit for exact PSL matches. (#2703)
Prior to this PR if a domain was an exact match to a public suffix
list entry the certificates per name rate limit was applied based on the
count of certificates issued for that exact name and all of its
subdomains.

This PR introduces an exception such that exact public suffix
matches correctly have the certificate per name rate limit applied based
on only exact name matches.

In order to accomplish this a new RPC is added to the SA
`CountCertificatesByExactNames`. This operates similar to the existing
`CountCertificatesByNames` but does *not* include subdomains in the
count, only exact matches to the names provided. The usage of this new
RPC is feature flag gated behind the "CountCertificatesExact" feature flag.

The RA unit tests are updated to test the new code paths both with and
without the feature flag enabled.

Resolves #2681
2017-05-02 13:43:35 -07:00
Roland Bracewell Shoemaker b82c244e65 Add stat for how often DNS responses are signed (#2716)
I'm interested in seeing both how often DNS responses we see are signed (mainly for CAA, but
also interested in other query types). This change adds a new counter, `Authenticated`, that can
be compared against the `Successes` counter to find the percentage of signed responses we see.
The counter is incremented if the `msg.AuthenticatedData` bit is set by the upstream resolver.
2017-05-02 10:57:11 -07:00
Roland Bracewell Shoemaker 2ecb8bf7a5 Remove confusing SetEdns0 call (#2718)
Remove `SetEdns0` call in `bdns.exchangeOne`. Since we talk over TCP to the production
resolver and we don't do any local validation of DNSSEC records adding the EDNS0 OPT
record is pointless and confusing. Testing against a local `unbound` instance shows you
 don't need to set the DO bit for DNSSEC requests/validation to be done at the resolver
level.
2017-05-02 10:55:47 -07:00
Jacob Hoffman-Andrews 8e80a22493 Remove RequestTime and ResponseTime from WFE log (#2708)
Fixes #2707.
2017-04-27 14:55:31 -07:00
Daniel McCarney 0282f9f48e Embeds detail msg for RejectedIdentifier and InvalidEmail probs. (#2704)
In #2583 the internal error usage was reworked. Previously the rejected
identifier and invalid email problems were constructed directly with
a meaningful detail message and then piped straight through the
`core.ProblemDetailsForError` function unaltered allowing the detail to
make it all the way through to the error returned by the WFE to the
client.

Since the refactor Boulder has not been appending the detail message for
these two problem types in `problemDetailsForBoulderError`, making the
errors harder to diagnose client-side.

This commit restores the previous behaviour by updating
`problemDetailsForBoulderError`. The `TestProblemDetailsFromError` unit
test is also updated to check that the correct amount of detail is being
embedded in the problem detail based on the error type.
2017-04-26 14:56:54 -07:00
Jacob Hoffman-Andrews d542960a35 Remove statsd version of RPC stats (#2693)
* Remove statsd-style RPC stats.

* Remove tests for old code.
2017-04-25 10:10:35 -04:00
Jacob Hoffman-Andrews d99800ecb1 Remove some last traces of AMQP. (#2687)
Fixes #2665
2017-04-20 10:43:17 -07:00
Jacob Hoffman-Andrews d59188c676 Use pattern to determine endpoint metrics. (#2689)
This ensures we don't create infinite metrics based on users hitting
non-existent endpoints.
2017-04-20 13:14:47 -04:00
Jacob Hoffman-Andrews eccca3ccd4 Dockerfile/docker-compose.yml cleanups (#2682)
Removes the reliance on `$GOPATH` being set in order to use `docker-compose`. Also removes
a few unnecessary commands from the `Dockerfile` that were no longer doing anything. If you
get weird errors along the lines of `oci runtime error: cannot chdir to ...` you will need to
`docker-compose rm; docker-compose build; docker-compose up` to fix them.

Fixes #2660.
2017-04-20 09:08:55 -07:00
Brian Smith 2781549618 CA: Use Prometheus for counting issued certificates. (#2690)
Prepare for counting precertificates by paramaterizing the counter
on "purpose".
2017-04-19 11:06:04 -07:00
David Calavera cc5ee3906b Refactor IsSane and IsSane* to return useful errors. (#2685)
This change changes the returning values from boolean to error.

It makes `checkConsistency` an internal function and removes the
optional argument in favor of making checks explicit where they are
used.

It also renames those functions to CheckConsistency* to not
give the impression of still returning boolean values.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2017-04-19 12:08:47 -04:00
Jacob Hoffman-Andrews 17e697fde8 Add boulderdash Grafana dashboard in JSON. (#2683) 2017-04-18 09:54:03 -04:00
Lucas Amorim 3c4873bb5c Returns an Internal Server Error on grpc/db timeouts (#2624) 2017-04-17 19:50:03 -07:00
Roland Shoemaker 0131a96a71 Dockerfile/docker-compose.yml cleanups 2017-04-14 14:59:31 -07:00
Jacob Hoffman-Andrews 9c1e8e6764 Call logging.basicConfig() in chisel. (#2679)
Without this, chisel would fail to log even with LOGLEVEL set to 0.
2017-04-14 10:08:53 -04:00
Jacob Hoffman-Andrews 6155ec9ad2 Update divergences doc to describe rel=next. (#2678)
Based on a conversation with an implementer who found this confusing (since
Certbot 0.11 uses them).
2017-04-14 10:08:10 -04:00
Jacob Hoffman-Andrews 99ce9cc51c Add Prometheus collection for WFE to default config. (#2675) 2017-04-13 10:07:28 -07:00
Roland Bracewell Shoemaker b38077e02e Change prefixdb semantics (#2674)
Instead of executing the prefix for every statement only do it when creating the connection.
Leaves most of the existing naming conventions alone but updates the relevant comments
to reflect setting variables is now connection level instead of statement.

Fixes #2673.
2017-04-12 21:57:58 -07:00
Jacob Hoffman-Andrews d849f58cec Fix "valiation typo in VA. (#2676) 2017-04-12 11:12:22 -07:00
Jacob Hoffman-Andrews dcbe7e0895 Increase readTimeout in TestTimeouts. (#2671)
Should decrease flakiness in this test. Fixes #2564
2017-04-09 15:32:02 -04:00
Brian Smith 647b448cc1 CA: Don't add cert DER to audit log for OCSP failures. (#2667)
First, commit c0ad8d9040 (PR #2658)
had a minor bug: It didn't update the "pem=" in the audit log
message to "cert=" to be consistent with the rest of the code.

But, more importantly, we don't need to include the cert DER in the
audit log at this point because we've already logged the DER and its
serial number prior to this. Thus, at this point logging the serial
number is good enough.
2017-04-07 13:50:59 -07:00