Commit Graph

137 Commits

Author SHA1 Message Date
Jacob Hoffman-Andrews 2f75214a88 Add limit on number of pending authorizations.
Adds a new method CountPendingAuthorizations to SA.
2015-10-14 13:50:43 -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
Jacob Hoffman-Andrews c80206d424 Respond to review feedback. 2015-10-08 23:14:25 -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
Jacob Hoffman-Andrews acdb1fa91b Merge branch 'master' into issued-names-limit-2
Conflicts:
	mocks/mocks.go
	rpc/rpc-wrappers.go
	sa/storage-authority.go
2015-10-07 17:20:36 -07:00
Jacob Hoffman-Andrews 1d91d81158 Implement rate limiting by domain name. 2015-10-04 21:04:26 -07:00
Richard Barnes def19e324b Fix golint in ./sa 2015-10-04 21:03:34 -04:00
Jeff Hodges a07e3b4e13 Merge branch 'master' into paranoid-key 2015-10-01 16:17:32 -07:00
Jacob Hoffman-Andrews e5a501de27 Rename `issued` back to `notBefore`. 2015-10-01 15:59:30 -07:00
Jeff Hodges d433062f16 Merge branch 'master' into issued-names-count 2015-10-01 14:19:14 -07:00
Jacob Hoffman-Andrews 6963811ab5 Merge remote-tracking branch 'le/master' into paranoid-key
Conflicts:
	core/util.go
2015-10-01 14:13:05 -07:00
Jacob Hoffman-Andrews 685c6e4206 Use stored key to verify JWS POSTs
instead of submitted key. This minimizes the chances of unexpected JWK fields in
the submitted key altering its interpretation without altering the lookup in the
registrations table.

In the process, fix handling of NoSuchRegistration responses.

Fixes https://github.com/letsencrypt/boulder/issues/865.
2015-09-29 23:37:16 -07:00
Jacob Hoffman-Andrews 2dec5c740a Document limit on CountCertificatesByName. 2015-09-29 17:34:01 -07:00
Jacob Hoffman-Andrews 5cc50c1a87 Fix capitalization 2015-09-29 16:58:02 -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
Roland Shoemaker 96afd94e88 Review fixes
* Rewrite JSONDuration as ConfigDuration that can handle both JSON and YAML unmarshaling
* Factor out RPC certificate count request struct
* Return 429 to WFE on rate limit exceeded
* Fix wonky RateLimitPolicy comment
2015-09-25 14:39:53 -07:00
Roland Shoemaker 6e3f0e18c6 Merge branch 'master' into cert-limit 2015-09-25 14:08:09 -07:00
Roland Shoemaker 6f41cc9e39 Add issuance rate limiting based on total number of certificates issued in a window
Since the issuance count requires a full table scan a RA process local cache of the
count is kept and expired after 30 minutes.
2015-09-24 12:54:38 -07:00
Jacob Hoffman-Andrews af7f4eb32f Remove GetCertificateByShortSerial. 2015-09-22 16:59:38 -07:00
Jacob Hoffman-Andrews c858b4d430 Consolidate serial number validity checking.
Also, set the requirement to be hexadecimal and <36 characters, rather than
exactly 36 characters.
2015-09-22 14:03:29 -07:00
Jacob Hoffman-Andrews 02314f4041 Implement the new 144-bit mostly-random serial.
To keep the change small, I have not yet completely removed the
GetCertificateByShortSerial method from interfaces and the RPC. I will do taht
in a follow up change.
2015-09-21 13:10:16 -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
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
Jeff Hodges 4109b8b3e6 rename pending_authz table to pendingAuthorizations 2015-09-04 14:51:52 -07:00
Jeff Hodges 40d1c446d9 correct ca and sa revocation code and tests
The ca's TestRevoke was failing occasionally.

The test was saying "has the certificate's OCSPLastUpdated been set to a
time within the last second?" as a way to see if the revocation updated
the OCSPLastUpdated. OCSPLastUpdated was not being set on revocation,
but the test still passed most of the time.

The test still passed most of the time because the creation of the
certificate (which also sets the OCSPLastUpdated) has usually happened
within the last second. So, even without revocation, the OCSPLastUpdated
was set to something in the last second because the test is fast.

Threading a clock.FakeClock through the CA induced the test to fail
consistently. Debugging and threading a FakeClock through the SA caused
changes in times reported but did not fix the test because the
OCSPLastUpdated was simply not being updated. There were not tests for
the sa.MarkCertificateRevoked API that was being called by
ca.RevokeCertificate.

Now the SA has tests for its MarkCertificateRevoked method. It uses a
fake clock to ensure not just that OCSPLastUpdated is set correctly, but
that RevokedDate is, as well. The test also checks for the
CertificateStatus's status and RevocationCode changes.

The SA and CA now use Clocks throughout instead of time.Now() allowing
for more reliable and expansive testing in the future.

The CA had to gain a public Clock field in order for the RA to use the
CertificateAuthorityImpl struct without using its constructor
function. Otherwise, the field would be nil and cause panics in the RA
tests.

The RA tests are similarly also panicking when the CAImpl attempts to
log something with its private, nil-in-those-tests log field but we're
getting "lucky" because the RA tests only cause the CAImpl to log when
they are broken.

There is a TODO there to make the CAImpl's constructor function take
just what it needs to operate instead of taking large config objects and
doing file IO and such. The Clk field should be made private and the log
field filled in for the RA tests.

Fixes #734.
2015-09-04 11:52:37 -07:00
Roland Shoemaker 5066acec92 Merge pull request #690 from letsencrypt/delete_sequence
remove unused sequence from authz table
2015-08-28 13:55:06 -07:00
Jeff Hodges 20686fd535 remove unused sequence from authz table
Fixes #687.
2015-08-27 21:21:47 -07:00
Roland Shoemaker a4aa450ee6 Switch to custom revocation code type 2015-08-27 17:09:41 -07:00
Jeff Hodges 7b6f2894f7 add goose as the migration tool
This has required some substantive changes to the tests. Where
previously the foreign key constraints did not exist in the tests, now
that we use the actual production schema, they do. This has mostly led
to having to create real Registrations in the sa, ca, and ra tests. Long
term, it would be nice to fake this out better instead of needing a real
sa in the ca and ra tests.

The "goose" being referred to is <https://bitbucket.org/liamstask/goose>.

Database migrations are stored in a _db directory inside the relevant
owner service (namely, ca/_db, and sa/_db, today).

An example of migrating up with goose:

    goose -path ./sa/_db -env test up

An example of creating a new migration with goose:

    goose -path ./sa/_db -env test create NameOfNewMigration sql

Notice the "sql" at the end. It would be easier for us to manage sql
migrations. I would like us to stick to only them. In case we do use Go
migrations in the future, the underscore at the beginning of "_db" will
at least prevent build errors when using "..." with goose-created Go
files. Goose-created Go migrations do not compile with the go tool but
only with goose.

Fixes #111
Unblocks #623
2015-08-25 12:02:31 -07:00
Roland Shoemaker 4c118b9b2a De-dup update challenge stuff 2015-08-20 20:32:12 -07:00
Roland Shoemaker d558d0b1fa Add ORDER BYs to UpdatePending and Finalize methods since we need the challenge IDs 2015-08-20 14:47:21 -07:00
Roland Shoemaker 1ae613bd87 Review fixes 2015-08-20 12:14:13 -07:00
Roland Shoemaker 69edf779b5 Switch to real model vs. view 2015-08-18 16:38:06 -07:00
Roland Shoemaker 015e089b7d Review fixes pt. 2 2015-08-18 13:33:25 -07:00
Roland Shoemaker eaa1ef9f0d Intial review cleanups 2015-08-18 11:19:52 -07:00
Roland Shoemaker 3fe109d33c Merge master 2015-08-15 16:03:01 -07:00
Jeff Hodges 5e97aa23c6 use MariaDB in the unit tests
And delete the uses of sqlite3
2015-08-14 17:13:15 -07:00
Roland Shoemaker a01a15df07 Switch to challengeModel instead of core.Challenge, various scehma fiddling and trickery 2015-08-14 16:08:46 -07:00
Roland Shoemaker 7455df2eee Cleanups and test fixes 2015-08-13 20:48:29 -07:00
Roland Shoemaker 5be6e588ee Initial work 2015-08-13 20:24:25 -07:00
Jeff Hodges 390464ddf4 correct unique indexing of Registrations
Fixes #579 (which blocks #132).

This changes the SA to use a unique index on the sha256 of a
Registration's JWK's public key data instead of on the full serialized
JSON of the JWK. This corrects multiple problems:

 1. MySQL/Mariadb no longer complain about key's being larger than the
 largest allowed key size in an index
 2. We no longer have to worry about large keys not being seen as unique
 3. We no longer have to worry about the JWK's JSON being serialized with its inner keys in different orders and causing incorrectly empty queries or non-unique writes.

This change also hides the details of how Registrations are stored in
the database from the other services outside of SA. This will give us
greater flexibility if we need to move them to another database, or
change their schema, etc.

Also, adds some tests for NoSuchRegistration in the SA.
2015-08-06 14:19:19 -07:00
Jeff Hodges 1c08a27748 use GetRegistration RPC outside of SA
We move the admin-revoker and expiration-mailer to using the
SA.GetRegistration RPC method instead of digging into the database
itself.

This allows the hiding of the registration model layer inside of SA, so
we can do fancy things with sha256 for the unique index inside of
it. This will happen in a later commit. See #579.

By exposing fewer details about how Registration is stored, we gain more
flexibility to fix up how its stored.

In the expiration-mailer, the performance hit for the early filtering of
mailto is likely neglibible and possibly even a benefit given the cost
of joins to the memory of MySQL.

If need be, we can built a bulk RPC layer for SA that provides the data
we need in findExpiringCertificates. It'll be easier than trying to
scale and change the storage layer underneath for each consumer.
2015-08-06 02:10:54 -07:00
Jeff Hodges c32790a28c remove unused bucket field from SQLStorageAuthority 2015-07-31 14:05:32 -07:00
bifurcation 60e82f6df3 Merge pull request #544 from letsencrypt/mysql-uri
Make sure MySQL DB URI contains 'parseTime=true'
2015-07-29 16:53:32 -04:00
Roland Shoemaker 272fbbd480 Merge pull request #541 from r0ro/remove-authz-newcert
Remove the need for a client to send authorizations url when requesting new certificate
2015-07-29 13:10:46 -07:00
Romain Fliedel 236a90afda fix sql request to get only valid authorizations. 2015-07-28 11:45:08 +02:00
Roland Shoemaker ae06aeee30 Move parseTime check to NewDbMap so binaries that don't use a SSA still get the checking 2015-07-27 20:03:20 -07:00
Roland Shoemaker 33b59530c6 typo 2015-07-27 17:46:00 -07:00