Commit Graph

82 Commits

Author SHA1 Message Date
Jacob Hoffman-Andrews fe6fab8821
Remove fqdnsets_old workaround (#6054)
Fixes #5670
2022-04-21 16:39:35 -07:00
Samantha 82c20145c9
SA: Add support for querying which incidents impact a given serial (#6026)
First commit adding support for tooling to aid in the tracking and remediation
of incidents.

- Add new SA method `IncidentsForSerial`
- Add database models for `incident`s and `incidentCert`s
- Add protobuf type for `incident`
- Add database migrations for `incidents`, `incident_foo`, and `incident_bar`
- Give db user `sa` permissions to  `incidents`, `incident_foo`, and
  `incident_bar`
  
 Part Of #5947
2022-04-07 14:44:59 -07:00
Aaron Gable f21ba0d8a7
Check both current and old fqdnSets tables (#5668)
In `sa.checkFQDNSetExists`, query both the normal `fqdnSets` and the
`fqdnSets_old` tables. The `fqdnSets` table was recently truncated to
only have 7 days worth of data, but this helper function is used to
bypass other rate limits if there exists a prior certificate for the
exact same set of names, and that functionality cares about at least
90 days worth of data. Therefore we need to query both tables, at least
until `fqdnSets` contains 90 days worth of data again.

Also make a variety of other changes to support this change: creating
the `fqdnSets_old` table in our test environment, documenting various
places where it needs to be cleaned up, and removing some unused code.

Fixes #5671
2021-09-24 12:34:25 -07:00
Samantha 8ea2657341
SA: Promote partition migrations from db-next (#5502)
Part of #5467
2021-06-23 11:52:35 -07:00
Aaron Gable a7f5917fb1
Fix bad merge from #5305 (#5309)
Remove two database migration files which were added immediately
prior to 5305, and which should have been removed by it, but were
left in place due to weird git merge semantics.
2021-02-25 13:03:36 -07:00
Aaron Gable f92cefe0c8
Collapse DB migrations into a single file (#5305)
Remove five years of built-up database goose migration files.
Replace them with a single file which contains a snapshot of
the current database schema, which has been confirmed to
be identical to the current schema live in production.

Part of #5254
2021-02-25 09:50:27 -08:00
Aaron Gable 0fdaead9b4
Move DropTableChallenges migration to prod (#5302)
This table has been dropped from our staging and prod
databases, so this migration can move from _db-next to _db.

Part of #5254
2021-02-23 16:57:20 -08:00
Aaron Gable 5a081515a7
Drop never-used CRLs table (#5303)
This table was part of the initial schema, but no Boulder
code has ever written to or read from it.

Part of #5254
2021-02-23 16:09:33 -08:00
Aaron Gable 88ea4432be
Reify RemoveOldAuthzTables migration (#5255)
This migration has happened in prod (IN-5278) so we can move this
migration file from _db-next to _db.

Part of #5252
2021-01-27 13:30:36 -08: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 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 b3856042f3
Move completed migrations to sa/_db from _db-next (#4793) 2020-04-23 13:40:45 -07:00
Jacob Hoffman-Andrews fead807c7c Make PrecertificateOCSP the default behavior. (#4465)
In the process, rename generateOCSPAndStoreCertificate to just
storeCertificate, because that function doesn't generate OCSP anymore;
instead the OCSP is generated (and stored) at precertificate issuance
time.
2019-10-09 17:11:58 -07:00
Jacob Hoffman-Andrews b7250c1d43
integration: test for DisableAuthz2Orders. (#4390)
To make this work, I changed the twenty_days_ago setup to use
`config-next` when the main test phase is running `config`. That, in
turn, made the recheck_caa test fail, so I added a tweak to that.

I also moved the authzv2 migrations into `db`. Without that change,
the integration test would fail during the twenty_days_ago setup because
Boulder would attempt to create authzv2 objects but the table wouldn't
exist yet.
2019-08-08 17:07:29 -07:00
Jacob Hoffman-Andrews 09ba859366 SA: Deprecate FasterRateLimit feature flag (#4210)
This makes the behavior behind that flag the default.
2019-05-09 15:06:21 -04:00
Jacob Hoffman-Andrews a6597b9f12 Change pendingAuthorizations indexes for better performance. (#3775)
There are two main queries we do against pendingAuthorizations: counting pending authzs
for rate limiting, and looking up existing authorizations for reuse. Neither of these is served
perfectly by our current (regID, expires) index. The index works well in some conditions but
not others. This change adds two more specific indexes to replace the existing ones.

The below set of EXPLAINs demonstrates the new indexes in use. Note that in order to
get MariaDB to make proper use of the new index, I had to create a local account and
fill it with pending authzs using a modified chisel.py.

The `registrationID`, `status`, `expires` index is used for the case when an account creates
and then deactivates a lot of authzs, since deactivated authzs stay in the pending table
and create performance issues. Adding an index that includes status can fix those performance
issues. The last section of statements logs below, after I `UPDATE` all the pending authorizations
to be `deactivated`, demonstrates the speed difference in the count query (check the `rows` count).

```
mysql> SHOW CREATE TABLE pendingAuthorizations \G                                                                     *************************** 1. row ***************************
       Table: pendingAuthorizations
Create Table: CREATE TABLE `pendingAuthorizations` (
  `id` varchar(255) NOT NULL,
  `identifier` varchar(255) NOT NULL,
  `registrationID` bigint(20) NOT NULL,
  `status` varchar(255) NOT NULL,
  `expires` datetime DEFAULT NULL,
  `combinations` varchar(255) NOT NULL,
  `LockCol` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `regId_expires_idx` (`registrationID`,`expires`),
  CONSTRAINT `regId_pending_authz` FOREIGN KEY (`registrationID`) REFERENCES `registrations` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

mysql> EXPLAIN SELECT COUNT(*) FROM pendingAuthorizations WHERE status = 'pending' AND expires > NOW() \G             *************************** 1. row ***************************                                                                   id: 1
  select_type: SIMPLE
        table: pendingAuthorizations
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 270
        Extra: Using where
1 row in set (0.01 sec)

mysql> EXPLAIN SELECT COUNT(*) FROM pendingAuthorizations WHERE registrationID = 2003 AND status = 'pending' AND expires > NOW() \G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: pendingAuthorizations
         type: ref
possible_keys: regId_expires_idx
          key: regId_expires_idx
      key_len: 8
          ref: const
         rows: 150
        Extra: Using index condition; Using where
1 row in set (0.00 sec)

mysql> EXPLAIN SELECT id, identifier, registrationID, status, expires, combinations, LockCol FROM pendingAuthorizations WHERE registrationID = 2003 AND identifier = '{\"type\":\"dns\",\"value\":\"23.com\"}' AND status = 'pending' AND expires > NOW() ORDER BY expires ASC LIMIT 1 \G                                                                         *************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: pendingAuthorizations
         type: ref
possible_keys: regId_expires_idx
          key: regId_expires_idx
      key_len: 8
          ref: const
         rows: 150
        Extra: Using index condition; Using where
1 row in set (0.00 sec)

mysql>
mysql> ALTER TABLE `pendingAuthorizations`
    ->   ADD INDEX `identifier_registrationID_status_expires_idx` (
    ->     `identifier`, `registrationID`, `status`, `expires`),
    ->   ADD INDEX `registrationID_status_expires_idx` (
    ->     `registrationID`, `status`, `expires`),
    ->   DROP INDEX `regId_expires_idx`;
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> EXPLAIN SELECT COUNT(*) FROM pendingAuthorizations WHERE registrationID = 2003 AND status = 'pending' AND expires > NOW() \G                                                                                                         *************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: pendingAuthorizations
         type: range
possible_keys: registrationID_status_expires_idx
          key: registrationID_status_expires_idx
      key_len: 781
          ref: NULL
         rows: 150
        Extra: Using where; Using index
1 row in set (0.00 sec)

mysql> EXPLAIN SELECT id, identifier, registrationID, status, expires, combinations, LockCol FROM pendingAuthorizations WHERE registrationID = 2003 AND identifier = '{\"type\":\"dns\",\"value\":\"23.com\"}' AND status = 'pending' AND expires > NOW() ORDER BY expires ASC LIMIT 1 \G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: pendingAuthorizations
         type: range
possible_keys: identifier_registrationID_status_expires_idx,registrationID_status_expires_idx
          key: identifier_registrationID_status_expires_idx
      key_len: 1548
          ref: NULL
         rows: 1
        Extra: Using index condition
1 row in set (0.00 sec)

mysql> UPDATE pendingAuthorizations SET status = 'deactivated' WHERE registrationID = 2003;
Query OK, 150 rows affected (0.02 sec)
Rows matched: 150  Changed: 150  Warnings: 0

mysql> EXPLAIN SELECT COUNT(*) FROM pendingAuthorizations WHERE registrationID = 2003 AND status = 'pending' AND expires > NOW() \G                                                                                                         *************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: pendingAuthorizations
         type: range
possible_keys: registrationID_status_expires_idx
          key: registrationID_status_expires_idx
      key_len: 781
          ref: NULL
         rows: 1
        Extra: Using where; Using index
1 row in set (0.01 sec)

mysql> 
mysql> ALTER TABLE `pendingAuthorizations`
    ->   DROP INDEX `identifier_registrationID_status_expires_idx`,
    ->   DROP INDEX `registrationID_status_expires_idx`,
    ->   ADD INDEX `regId_expires_idx` (`registrationID`,`expires`);
Query OK, 0 rows affected (0.04 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> EXPLAIN SELECT COUNT(*) FROM pendingAuthorizations WHERE registrationID = 2003 AND status = 'pending' AND expires > NOW() \G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: pendingAuthorizations
         type: ref
possible_keys: regId_expires_idx
          key: regId_expires_idx
      key_len: 8
          ref: const
         rows: 150
        Extra: Using index condition; Using where
1 row in set (0.00 sec)
```
2018-06-26 10:49:20 -07:00
Jacob Hoffman-Andrews 4a961c3bc8 Ungate config-next for wfe2 and Wildcards. 2018-03-14 13:18:37 -07:00
Jacob Hoffman-Andrews f6ff59c9ab Move db-next migrations into db. (#3379)
These have now all been applied in production.
2018-01-18 15:13:21 -05:00
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