Commit Graph

64 Commits

Author SHA1 Message Date
Daniel McCarney 5430c51e20 Move two migrations from `sa/_db-next/ to `sa/_db/`. (#2588)
Both the `20160818140745_AddRegStatus.sql` and
`20160914105917_RemoveChallengesAcctKeyAndTLS.sql` migrations have been
applied in production and can be moved out of `sa/_db-next/` to reflect
this fact.
2017-02-27 10:41:50 -08:00
Daniel McCarney 4c9cf065a8 `certificateStatus` table optimizations (Part One) (#2177)
This PR adds a migration to create two new fields on the `certificateStatus` table: `notAfter` and `isExpired`. The rationale for these fields is explained in #1864. Usage of these fields is gated behind `features.CertStatusOptimizationsMigrated` per [CONTRIBUTING.md](https://github.com/letsencrypt/boulder/blob/master/CONTRIBUTING.md#gating-migrations). This flag should be set to true **only** when the `20160817143417_CertStatusOptimizations.sql` migration has been applied.

Points of difference from #2132 (the initial preparatory "all-in-one go" PR):
**Note 1**: Updating the `isExpired` field in the OCSP updater can not be done yet, the `notAfter` field needs to be fully populated first - otherwise a separate query or a messy `JOIN` would have to be used to determine if a certStatus `isExpired` by using the `certificates` table's `expires` field. 
**Note 2**: Similarly we can't remove the `JOIN` on `certificates` from the `findStaleOCSPResponse` query yet until all DB rows have `notAfter` populated. This will happen in a separate **Part Two** PR.
2016-09-30 14:52:19 -04:00
Roland Bracewell Shoemaker 2c966c61b2 Revert "Allow account deactivation (#2138)" (#2188)
This reverts commit 6f3d078414, reversing
changes made to c8f1fb3e2f.
2016-09-19 11:20:41 -07:00
Roland Shoemaker dbf9afa7d6 Review fixes pt. 1 2016-08-25 16:28:58 -07:00
Roland Shoemaker 003158c9e3 Initial impl 2016-08-18 14:12:09 -07:00
Daniel McCarney 190ff2577d Add index to certificates table's issued field (#1876)
As detailed in issue #1872 the getSerialsIssuedSince function of the ocsp-updater cmd performs with poor runtime, likely due to a filesort and lack of index on the issued field.

This commit adds a migration to create a new index on the issued field.

* Add index to certificates table issued field.
* Rename index to use _idx suffix
2016-06-02 14:28:37 -07:00
Jacob Hoffman-Andrews ba47c61dd6 Remove UpdateOCSP and DeniedCSRs (#1866)
Neither is currently used.

* Remove unused UpdateOCSP method.
* Remove deniedCSRs
* Rename and fix migration.
2016-06-02 12:36:55 -07:00
Jacob Hoffman-Andrews d98eb634d1 Docker improvements.
Use bridged networking.

Add some files to .dockerignore to shrink the build state sent to Docker
daemon.

Use specific hostnames to contact services, rather than localhost.

Add instructions for adding those hostnames to /etc/hosts in non-Docker config.

Use DSN-style connect strings for DBs.

Remove localhost / 127.0.0.1 rewrite hack from create_db.sh.

Add hosts section with new hostnames.

Remove bin from .dockerignore.

SQL grants go to %

Short-circuit DB creation if already existing.

Make `go install` a part of Docker image build so that Docker run is much
faster.

Bind to 0.0.0.0 for OCSP responders so they can be reached from host, and
publish / expose their ports.

Remove ToSServerThread and test.js' fetch of ToS.

Increase the registrationsPerIP rate limit threshold. When issuing from a Docker
host, the 127.0.0.1 override doesn't apply, so the limit is quickly hit.

Update docker-compose for bridged networking. Note: docker-compose doesn't currently work, but should be close.

https://github.com/letsencrypt/boulder/pull/1639
2016-04-04 16:05:08 -07:00
Roland Shoemaker e5d3e9a1bc Make fqdnSets index across setHash and issued 2016-02-29 10:52:03 -08:00
Roland Shoemaker ee7a86e07d Review fixes 2016-02-22 22:56:07 -08:00
Roland Shoemaker 8fb87b7e7f Add exact FQDN set rate limit
Adds a new rate limit, certficatesPerFQDNSet, which counts certificates
with the same set of FQDNS using a table containing the hash of the dNSNames
mapped to a certificate serial. A new method is added to the SA in AddCertificate
to add this hash to the fqdnSets table, which is gated by a config bool.
2016-02-19 15:58:07 -08:00
Jeff Hodges 0ab76f75b4 remove old authz index on regID
Fixes #1126
2015-12-21 21:31:52 -08:00
Jeff Hodges 7de4ffdc36 add index for querying for the latest valid authz
Previously, when requesting a new certificate, we might churn through
many authz attempts to find the latest authz that was valid for a given
domain. There was an index on registration id, but a given registration
may have very many authzs. Think CDNs with one registration.

Updates #959
2015-11-05 14:27:55 -08:00
Jacob Hoffman-Andrews dd05ace030 Set up databases with restrictive user permissions.
Fixes https://github.com/letsencrypt/boulder/issues/898

Also removes currently-unused 'development' DB, and do initial migrations in
parallel, which shortens create_db.sh from 20 seconds to 10 seconds.

Changes ResetTestDatabase into two functions, one each for SA and Policy DBs,
which take care of setting up the DB connection using a special higher-privileged
user called test_setup.
2015-10-16 15:50:57 -07:00
Jacob Hoffman-Andrews 6fd50c4a71 Expand index on pending authz to include expires. 2015-10-15 11:55:31 -07:00
Roland Shoemaker bb9286b9c6 Add index on certificateStatus.status column 2015-10-09 16:14:31 -07:00
Roland Shoemaker f6e06cb604 Rename migration 2015-10-09 15:54:09 -07:00
Roland Shoemaker 1d710f91cd Merge branch 'master' into ocsp-revoke
Conflicts:
	cmd/ocsp-updater/main.go
2015-10-09 15:50:14 -07:00
Roland Shoemaker 8d1ea7291f Address review comments
OCSP-Responder attempts to read the OCSP response from the certificateStatus table,
if it cannot find a response there it reads the ocspResponses table to try to find a
response, if neither contains a response the not found bool is passed back to the
Responder.
2015-10-09 15:48:09 -07:00
Roland Shoemaker 10b6bb5548 Refactor certificate revocation and OCSP generation workflows
* Moves revocation from the CA to the OCSP-Updater, the RA will mark certificates as
  revoked then wait for the OCSP-Updater to create a new (final) revoked response
* Merges the ocspResponses table with the certificateStatus table and only use UPDATES
  to update the OCSP response (vs INSERT-only since this happens quite often and will
  lead to an extremely large table)
2015-10-08 18:55:11 -07:00
Jacob Hoffman-Andrews 487d08ec2e Add rate limiting by registration IP. 2015-10-08 15:47:08 -07:00
Jeff Hodges c11f533ed1 Merge branch 'master' into sig-reuse 2015-10-06 00:21:56 -07:00
Jeff Hodges 7ad8874f06 correct charset for contact column
Fixes #819.
2015-10-05 15:00:09 -07:00
Richard Barnes f3a40ac76c Address @jcjones comments 2015-10-04 23:24:06 -04:00
Richard Barnes 9414b1a37e Address @jmhodges comments and make tests pass 2015-10-03 14:47:17 -04:00
Richard Barnes 3f7247a80d Change to KeyAuthorization in sa 2015-10-03 13:18:33 -04:00
Richard Barnes 4c20bfe310 Merge master to sig-reuse 2015-10-01 18:58:35 -07:00
Roland Shoemaker 9dc7b2d682 Merge master 2015-10-01 17:23:48 -07:00
Roland Shoemaker 2d0dee4ce1 Daemonize the OCSP updater tool so we are constantly updating OCSP responses.
also moves the first OCSP responses generation from the CA to the OCSP updater. This patch lays the
ground work for moving CT submission and adding CT backfill to the OCSP updater.
2015-10-01 16:36:51 -07:00
Jacob Hoffman-Andrews e5a501de27 Rename `issued` back to `notBefore`. 2015-10-01 15:59:30 -07:00
Jacob Hoffman-Andrews 322da1f6a1 Remove LockCol from issuedNames.
Also, limit size of reversedName column to 640.
2015-09-30 16:38:36 -07:00
Jacob Hoffman-Andrews f476432449 Store a DB of issued names.
Add counting for issued names within a given time period.

First part of https://github.com/letsencrypt/boulder/issues/864.
2015-09-28 19:37:50 -07:00
Richard Barnes c44962d077 Adding missing migration file 2015-09-28 10:45:04 -04:00
Richard Barnes 1a9fd9b455 Update to latest ACME spec 2015-09-28 10:10:06 -04:00
Richard Barnes 54c924b436 Merge branch 'master' into sig-reuse 2015-09-27 18:29:14 -04:00
Jacob Hoffman-Andrews 3a58299953 Make UpdateSerialNumbers migration safer.
Previously, if we did an up migration, generated some certs, then did a
down migration, we would truncate some of the new-style serial numbers in a way
that would be hard to reverse.
2015-09-24 09:43:16 -07:00
Jeff Hodges 2a1d8042ac update previously made serial numbers to new style
Previously, 32 bytes were used for serial numbers but now we make
certificates with 36 bytes (see #823 and #813). Going forward, we want
them to be consistent, so we update our current ones by prepending 4
zeros to the them.

For the two existing certs, their leading datacenter id will be 0 in
production, but we take this hit because we can't adjust the serial
inside the certificates themselves, and can only pad them with zeroes in
the database.

Fixes #834
2015-09-22 21:34:23 -07:00
Roland Shoemaker ff6eca7a29 Submit all issued certificates to configured CT logs
Adds a new service, Publisher, which exists to submit issued certificates to various Certificate Transparency logs. Once submitted the Publisher will also parse and store the returned SCT (Signed Certificate Timestamp) receipts that are used to prove inclusion in a specific log in the SA database. A SA migration adds the new SCT receipt table.

The Publisher only exposes one method, SubmitToCT, which is called in a goroutine by ca.IssueCertificate as to not block any other issuance operations. This method will iterate through all of the configured logs attempting to submit the certificate, and any required intermediate certificates, to them. If a submission to a log fails it will be retried the pre-configured number of times and will either use a back-off set in a Retry-After header or a pre-configured back-off between submission attempts.

This changeset is the first of a number of changes ending with serving SCT receipts in OCSP responses and purposefully leaves out the following pieces for follow-up PRs.

* A fake CT server for integration testing
* A external tool to search the database for certificates lacking a full set of SCT receipts
* A method to construct X.509 v3 extensions containing receipts for the OCSP responder
* Returned SCT signature verification (beyond just checking that the signature is of the correct type so we aren't just serving arbitrary binary blobs to clients)

Resolves #95.
2015-09-17 18:11:05 -07:00
Richard Barnes 5d19a37783 Add authorized keys to DB/SA 2015-09-10 22:32:47 -04:00
Jacob Hoffman-Andrews ffcd1c866d Make challenge URI a display-time property.
Challenge URIs should be determined by the WFE at fetch time, rather than stored
alongside the challenge in the DB. This simplifies a lot of the logic, and
allows to to remove a code path in NewAuthorization where we create an
authorization, then immediately save it with modifications to the challenges.

This change also gives challenges their own endpoint, which contains the
challenge id rather than the challenge's offset within its parent authorization.
This is also a first step towards replacing UpdateAuthorization with
UpdateChallenge: https://github.com/letsencrypt/boulder/issues/760.
2015-09-09 16:23:45 -04:00
Jacob Hoffman-Andrews d137fce1f7 Merge pull request #751 from letsencrypt/rename_pending_authz
rename pending_authz table to pendingAuthorizations
2015-09-08 11:26:52 -04:00
Jacob Hoffman-Andrews c01bb8f88a Merge pull request #749 from letsencrypt/ocspResponses_not_null
disallow some null values in ocspResponses table
2015-09-08 11:26:27 -04:00
Jacob Hoffman-Andrews 997576eb2c Merge pull request #750 from letsencrypt/pending_authz_not_null
disallow some null values in pending_authz table
2015-09-08 11:06:28 -04:00
Roland Bracewell Shoemaker 7ba1a305fb Merge pull request #747 from letsencrypt/certificateStatus_not_null
disallow null values in certificateStatus table
2015-09-06 14:38:31 -07:00
Jeff Hodges 4109b8b3e6 rename pending_authz table to pendingAuthorizations 2015-09-04 14:51:52 -07:00
Jeff Hodges 762dc22895 disallow some null values in pending_authz table 2015-09-04 14:36:57 -07:00
Jacob Hoffman-Andrews dda671b282 Merge pull request #746 from letsencrypt/authz_null_expires
allow NULL expires in authz on validation failure
2015-09-04 16:43:28 -04:00
Jeff Hodges 7385000cfb disallow some null values in ocspResponses table 2015-09-04 13:25:26 -07:00
Jeff Hodges 856ff27d2a disallow null values in certificateStatus table 2015-09-04 12:24:48 -07:00
Jeff Hodges 6dcba1ae49 allow NULL expires in authz on validation failure
The RA did not have any code to test what occurred when a challenge
failed. This let in the authz schema change in #705.

This change sets the expires column in authz back to NULLable and fixes
the RA tests (including, using clock.Clocks in the RA).

Fixes #744.
2015-09-04 12:14:24 -07:00