Commit Graph

178 Commits

Author SHA1 Message Date
Roland Shoemaker 4a47aaed51 Merge master 2015-09-22 14:07:07 -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
Roland Shoemaker cc65beef3f Merge master 2015-09-15 14:52:40 -07:00
Jacob Hoffman-Andrews 71c682179e Switch to authorizationLifetime 2015-09-11 16:36:56 -04:00
Roland Shoemaker 346a8c1a01 Merge master 2015-09-10 13:47:19 -07:00
Roland Shoemaker 871a77c4b8 Merge master 2015-09-10 13:00:52 -07:00
Jacob Hoffman-Andrews 253d700d06 Merge branch 'master' into challenge-display-uri
Conflicts:
	cmd/boulder-ra/main.go
	ra/registration-authority.go
	ra/registration-authority_test.go
2015-09-10 15:44:21 -04:00
Jacob Hoffman-Andrews 998ffc79cb Do GoodKey checking in WFE. 2015-09-09 20:30:55 -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 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 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
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 af8299d607 Merge master 2015-09-03 11:36:08 -07:00
Jeff Hodges f33b103a01 Merge pull request #601 from letsencrypt/blacklist
Use DNS blacklist/whitelist DB
2015-09-02 11:04:31 -07:00
Jacob Hoffman-Andrews 97c93cd6fa Temporarily disable DNS challenge.
We're not planning to offer this one at launch (hopefully not long after,
though).
2015-08-31 21:26:12 -04:00
Roland Shoemaker e54d3d322e Merge branch 'master' into blacklist 2015-08-31 15:39:24 -07:00
Roland Shoemaker 1ad7bea579 Move PA construction out of other authority constructors 2015-08-31 15:33:03 -07:00
Roland Shoemaker e798362748 Merge branch 'master' into metrics-cleanup 2015-08-28 16:49:46 -07:00
Roland Shoemaker 88c2f95179 Cleanup authority creation 2015-08-28 15:03:02 -07:00
Richard Barnes 3d540ff481 Addressing review comments 2015-08-28 11:21:13 -04:00
Richard Barnes b5c177669d Merge branch 'master' into sig-misuse 2015-08-28 09:55:33 -04:00
Roland Shoemaker 764169667e Merge master 2015-08-27 11:21:18 -07:00
Richard Barnes b4d717b934 Fixing unit test failures 2015-08-26 16:02:20 -04:00
Richard Barnes 49eebc5cac Fix build issue in RA test 2015-08-26 15:28:47 -04:00
Roland Shoemaker 0e1e38011a Review fixes pt. 2 2015-08-26 12:09:15 -07:00
Roland Shoemaker be751bd948 Merge master 2015-08-25 16:52:24 -07:00
Richard Barnes c552984784 Merge master 2015-08-25 19:21:02 -04:00
Richard Barnes f3d4725051 Add a test for RA rejecting UpdateAuthorization 2015-08-25 19:12:23 -04:00
Richard Barnes c7eaece4da Have RA reject update by a different account key. 2015-08-25 17:50:26 -04:00
Richard Barnes 8868ac9dad Remove explicit account key from VA calls 2015-08-25 16:32:32 -04:00
Jeff Hodges 6b7bfb40d1 avoid needing a row to start serialNumber
Managing the single row needed in serialNumber is a bit of hassle in a
world where we delete all of the rows in all tables in our tests. Plus,
if someone does that on their development database, they have to drop
all the way to the start of the migrations and run them again. It's a
bummer.

Instead, use the MySQL id generation design as [described and used by
Flickr](https://code.flickr.net/2010/02/08/ticket-servers-distributed-unique-primary-keys-on-the-cheap/). That design
doesn't need a row at its first insert to work correctly.

(That post mentions maybe using `ON DUPLICATE KEY UPDATE`, but it has
subtle bugs that even using `LAST_INCREMENT_ID(id)` doesn't fix. This is
because `UPDATE` doesn't run on the first `INSERT` but the `INSERT` will
return 1. Then, id 1 will be returned again on the
second `INSERT` attempt because the `LAST_INCREMENT_ID(id)` will be 0
because no increment was done! All subsequent `INSERT` attempts will be off by
one.)

Fixes #649.
2015-08-25 13:14:17 -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 3cf1ea8e38 Cleaner/quicker rule list search & properly cleanup database 2015-08-24 15:46:37 -07:00
Roland Shoemaker 796baa0273 Merge master 2015-08-15 18:37:34 -07:00
Roland Shoemaker 4fb747ead1 Merge master 2015-08-15 16:50:57 -07:00
Jeff Hodges 7e12d6a33b add comments explaining db-related tech debt 2015-08-14 19:17:53 -07:00
Roland Shoemaker b9913a2b41 Review fixes 2015-08-14 17:14:02 -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 6970caa0e8 Various cleans and documentation fixes 2015-08-11 18:00:47 -07:00
Roland Shoemaker 8789f925cc Merge master 2015-08-11 16:39:31 -07:00
Roland Shoemaker c01c8a069b Use natural sort 2015-08-11 11:50:38 -07:00
Roland Shoemaker 1a2825138d Actually wire everything into the PADB 2015-08-06 16:57:38 -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 0f03494d56 use pointer to AcmeURL everywhere
This has the benefit of not requiring us to copy very fat url.URL
objects when we pass them to funcs or call their methods.
2015-08-05 18:23:38 -07:00
Richard Barnes 652702bd7f Merge master 2015-07-30 13:47:10 -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
Richard Barnes 9e87cef807 Further test fixes 2015-07-29 12:20:00 -04:00
Richard Barnes 4cac9da9fd Refactor simpleHttp challenge 2015-07-29 12:18:09 -04:00
Romain Fliedel 36cba96fb2 update tests after jwk encoding fix. 2015-07-28 16:25:30 +02:00
Romain Fliedel 2b275405c1 remove authorizations member for certificate request. 2015-07-27 20:26:56 +02:00
Jacob Hoffman-Andrews 9423467142 Switch to our own fork of go-jose.
This is the result of `godep save -r ./...` and
`git rm -r -f Godeps/_workspace/src/github.com/square`

Our fork is currently at the head of go-jose when Richard made the local nonce
changes, with the nonce changes added on top. In other words, the newly created
files are exactly equal to the deleted files.

In a separate commit I will bring our own go-jose fork up to the remote head,
then update our deps.

Also note: Square's go-jose repo contains a `cipher` package. Since we don't
make any changes to that package, we leave it imported as-is.
2015-07-24 14:39:00 -07:00
Jacob Hoffman-Andrews 620a012c62 Rewrite go-jose dependencies to our fork. 2015-07-24 14:16:01 -07:00
Roland Shoemaker 31f0674f03 Replace net.LookupMX with core.LookupMX using defined resolver 2015-07-21 22:36:29 -07:00
Tom Clegg 2d0be62966 Use mock syslog in test suites (except core and log). Drop SwitchLog(). 2015-07-21 17:06:39 -04:00
Roland Shoemaker f6248ef279 Flesh out DNS mock methods, and move them to their own sub-module instead of under test/ to avoid import loop, Add Loopback DNS resolver for core/dns_test.go 2015-07-07 22:31:44 +01:00
Roland Shoemaker 12589834a3 Merge master 2015-06-25 15:59:59 -07:00
Richard Barnes 5b33afba8e Reject weak CSR signing algorithms.
Also removed a commented-out CSR in the RA tests, and fixed a CA test that was (1) not testing what it meant to, and (2) used a different method from the other tests.
2015-06-23 21:47:31 -07:00
Roland Shoemaker 9edd2b8e07 Refactor StatsD metrics collection
- Moved HandlerTimer definition from various cmd/ binaries to cmd/shell.go
- Cleaned up HandlerTimer endpoint metrics
- Moved New... counter metrics from WFE to RA and add Updated... and Finalized... ones
- Added error code and problem type counter metrics to WFE
- Added validation type / status counter metrics to VA
- Consistently return the total RTT from LookupCAA, LookupCNAME, and LookupDNSSEC method
- Added DNS RTT timing metrics to VA for the various Loookup... methods
2015-06-21 23:28:10 -07:00
Roland Shoemaker 403af37a39 Hide Authorization.Expires field when uninitialized 2015-06-17 18:34:30 -07:00
J.C. Jones 41f5788c77 Correct most `go lint` warnings. (274 -> 5) 2015-06-16 22:18:28 -05:00
J.C. Jones fcaa6b9530 Issue #11: Add tests 2015-06-16 09:03:03 -05:00
Roland Shoemaker 01c41c1bd0 Merge pull request #354 from letsencrypt/344-internal_server_errors
Resolves Issue #344: Only send InternalServerError when needed
2015-06-15 15:57:04 -07:00
J.C. Jones dbe88d5d80 Issue #344: RA: Pull out a `validateContacts` method
- Created a `validateContacts` method to avoid duplicated code
- Added tests for `validateContacts` and `validateEmail`
- Fix error formatting in `validateEmail`:
  Discovered while testing `validateEmail` that, if no MX records are found,
  `err` is returned, not an empty array. As such, the error message
   was misleading, so I consoldated the conditions into one.
2015-06-15 16:46:50 -05:00
Jacob Hoffman-Andrews 80d5e50e42 Enable revocation by account key.
In addition to cert private key. This required modifying the GetCertificate*
functions to return core.Certificate instead of certificate bytes.
2015-06-15 12:33:50 -07:00
Roland Shoemaker f4ee29d1d3 Change all references from SimpleHTTPS -> SimpleHTTP 2015-06-12 11:22:04 -07:00
J.C. Jones 2ad15a4a85 Issue #309: Produce OCSP Responses immediately upon issuance, if at all possible.
This approach performs a best-effort generation of the first OCSP response during
certificate issuance. In the event that OCSP generation fails, it logs a warning at
the Boulder-CA console, but returns successfully since the Certificate was itself
issued.
2015-06-11 11:31:04 -05:00
Roland Shoemaker 0265b6f5d0 Merge upstream/master and fix conflicts 2015-06-10 12:43:11 -07:00
James 'J.C.' Jones 3acb03fdc9 Merge pull request #319 from letsencrypt/validate-contact
Validate contact details in the RA upon `new-reg`.
2015-06-06 07:57:16 -07:00
Roland Shoemaker 28db5aab45 Merge master 2015-06-06 02:47:55 +01:00
Roland Shoemaker 23b0cfa29f Extend email parsing 2015-06-06 02:46:51 +01:00
Roland Shoemaker 4ecd6d58b6 Merge master 2015-06-06 02:11:46 +01:00
Roland Shoemaker bb5c042cef Fix tests and various other cleanup 2015-06-06 02:06:35 +01:00
Roland Shoemaker 573e35ed56 Disallow multiple registrations with same key (and fix all related tests) 2015-06-04 20:21:59 +01:00
James 'J.C.' Jones 6a4aa8de3c Merge pull request #304 from letsencrypt/296-ca_tx_move
Issue #296: Fix erroneous transaction handling in CA
2015-06-03 22:10:43 -07:00
J.C. Jones abdc174be8 Issue #296: Fix erroneous transaction handling in CA
- Moved the transaction handling up to the `certificate-authority.go` file
- Simplified `certificate-authority-data.go`
- Created a mocks file in `test/` and reworked RA and CA to use it
- More audit logging to CA
2015-06-03 19:23:24 -07:00
Roland Shoemaker 78e621c95f further review fixes 2015-06-03 00:27:08 +01:00
Richard Barnes e8edbf5f21 Making capitalization consistent with Go standards 2015-06-01 02:08:47 -04:00
Richard Barnes 9917ca17f6 Clean up TODOs 2015-06-01 02:05:17 -04:00
Richard Barnes 2419559f5c Add validity interval checking 2015-05-31 14:23:09 -04:00
James 'J.C.' Jones 3e593d73c9 Merge pull request #262 from letsencrypt/ra-tests
Miscellaneous Fixes
2015-05-30 22:08:49 -07:00
bifurcation 441ce328c7 Merge pull request #255 from letsencrypt/202-ocsp-responder
Issue #202: Initial OCSP Responder
2015-05-30 13:10:50 -04:00
Richard Barnes 138c946bd6 Issue #43 and Issue #205 2015-05-30 11:11:33 -04:00
Jacob Hoffman-Andrews 92967f03b6 go fmt 2015-05-29 13:11:57 -07:00
Jacob Hoffman-Andrews b3b64fd10e Fix tests for goodkey branch. 2015-05-29 13:09:34 -07:00
Jacob Hoffman-Andrews 6a6a8aa72d Merge branch 'master' into goodkey
Conflicts:
	ca/certificate-authority.go
	ra/registration-authority.go
	ra/registration-authority_test.go
2015-05-29 12:26:24 -07:00
Roland Shoemaker 8846fd2c90 Merge upstream/master 2015-05-29 09:36:46 +01:00
J.C. Jones 4518f0bf17 Migrate CADB to using GORP. 2015-05-28 23:11:03 -07:00
J.C. Jones d1321f2d78 More RPC fixes for Issue #202
- NewPendingAuthorization now uses a core.Authorization object, so
  that foreign key constraints are followed
- core.Authorization now serializes RegistrationID to JSON, so it has to get
  blanked out in WFE before transmission to client.
- Remove ParsedCertificate from core.Certificate, as type x509.Certificate cannot
  be marshaled.
- Added AssertDeepEquals and AssertMarhsaledEquals to test-tools.go
- Caught several overloaded and misleadingly named errors in WFE
2015-05-28 11:05:55 -07:00
Roland Shoemaker 81c7466e97 add rpc-wrapper and interface code 2015-05-28 09:58:16 +01:00
J.C. Jones 343920cfe3 Fix integration test while running with MySQL
- Add SQL configuration options
- Increase the width of the authz and pending_authz tables' challenges field
- Make it configurable whether CREATE TABLE commands should run
2015-05-27 13:39:18 -07:00
Roland Shoemaker e1eeebce52 Only run validations against updated challenges (instead of everything) 2015-05-26 17:08:49 +01:00
Roland Shoemaker 4a94dbf8b9 remove debug statements and make validity period a config var for CA 2015-05-21 23:30:29 -07:00
Roland Shoemaker 0271cebd7a don't issue certs that expire after the CA intermediate 2015-05-21 23:02:58 -07:00
Roland Shoemaker 1c7d0d5411 gofmt touched files 2015-05-18 19:03:25 -07:00
Roland Shoemaker cf7f6f5db3 add RA regID checks 2015-05-18 18:53:48 -07:00
Jacob Hoffman-Andrews 61be79e51d Check that cert key != account key. 2015-05-18 15:20:02 -07:00
Roland Shoemaker e1ba291019 Store registration ID with certificate 2015-05-16 13:47:51 -07:00
Roland Shoemaker faa1d5ac45 review cleanups 2015-05-16 13:25:36 -07:00
Roland Shoemaker e233fdaa61 switch authz and pending_authz to store registration ID instead of key (and update all the random stuff they touched) 2015-05-14 14:14:36 -07:00
Jacob Hoffman-Andrews aa8c20f84a Fixes in response to review feedback. 2015-05-13 17:36:39 -07:00