Commit Graph

293 Commits

Author SHA1 Message Date
Roland Bracewell Shoemaker c8f1fb3e2f Remove direct usages of go-statsd-client in favor of using metrics.Scope (#2136)
Fixes #2118, fixes #2082.
2016-09-07 19:35:13 -04:00
Blake Griffith 344a312905 Remove audit comments -- closes #2129 (#2139)
Closes #2129

* Remove audit comments.
* Nuke doc/requirements/*
2016-08-25 18:23:42 -07:00
Roland Bracewell Shoemaker 91bfd05127 Revert #2088 (#2137)
* Remove oldx509 usage

* Un-vendor old crypto/x509, crypto/x509/pkix, and encoding/asn1
2016-08-23 14:01:37 -04:00
Ben Irving 573d1f1669 Stop logging full PEM objects (#2090)
Previously, the CA would log the full PEM encoded certificate signing request and the signed certificate. This PR, removes that, and logs a base64 encoded version of the request and the certificate.

Due to the fact that cfssl returns the certificate in PEM format regardless, we decode the certificate into DER and log the base64 version. If there is any failure in the decoding from PEM to DER, the CA will log the PEM encoded version of the certificate (this is the only case).

Furthermore, the Signing Success message was moved after the certificate is checked for 0 length and decoded into DER, which seems to make logical sense to me.

Fixes #1968
2016-07-28 13:38:26 -07:00
Jacob Hoffman-Andrews 474b76ad95 Import forked x509 for parsing of CSRs with empty integers (#2088)
Part of #2080.

This change vendors `crypto/x509`, `crypto/x509/pkix`, and `encoding/asn1` from  1d5f6a765d. That commit is a direct child of the Go 1.5.4 release tag, so it contains the same code as the current Go version we are using. In that commit I rewrote imports in those packages so they depend on each other internally rather than calling out to the standard library, which would cause type disagreements.

I changed the imports in each place where we're parsing CSRs, and imported under a different name `oldx509`, both to avoid collisions and make it clear what's going on. Places that only use `x509` to parse certificates are not changed, and will use the current standard library.

This will unblock us from moving to Go 1.6, and subsequently Go 1.7.
2016-07-28 10:38:33 -04:00
Ben Irving 1336c42813 Replace all log.Err calls with log.AuditErr (#1891)
* remove calls to log.Err()
* go fmt
* remove more occurrences
* change AuditErr argument to string and replace occurrences
2016-06-06 16:27:16 -04:00
Jacob Hoffman-Andrews 92df4d0fc2 Rename authorities to shorter names. (#1878)
Fixes #1875.
2016-06-03 13:35:28 -07:00
Ben Irving a713823cd5 Remove most instances of blog.Get() (#1870)
In this PR, logger is passed to the following callers:
  NewWebFrontEndImpl
  NewCertificateAuthorityImpl
  NewValidationAuthorityImpl
  NewAmqpRPCServer
  newUpdater
  NewRegistrationAuthorityServer

This reduces the usage of a global singleton logger and allows tests to consistently use a mock logger.

Fixes #1642

* remove blog.Get() in wfe
* remove blog.Get() from va
* remove Blog.Get() from ca
* remove blog.Get() from oscp updater, ampq rpc server, registration authority server
* removed some pointless logging code
* remove one added newline
* fix format issue
* fix setup function to return *blog.Mock instead of being passed in
* remove useless blog.NewMock() call
2016-06-02 14:26:39 -07:00
Jacob Hoffman-Andrews 9a4b979397 Move goodkey and nonce out of core (#1869) 2016-06-02 11:29:58 -07:00
Roland Bracewell Shoemaker 54573b36ba Remove all stray copyright headers and appends the initial line to LICENSE.txt (#1853) 2016-05-31 12:32:04 -07:00
Roland Bracewell Shoemaker 5abe7e3cdf Move CSR normalization/verification to their own methods (#1826)
* Split CSR testing and name hoisting into own functions, verify CSR in RA & CA

* Move tests around and various other fixes

* 1.5.3 doesn't have the needed stringer

* Move functions to their own lib

* Remove unused imports

* Move MaxCNLength and BadSignatureAlgorithms to csr package

* Always normalizeCSR in VerifyCSR and de-export it

* Update comments
2016-05-26 14:17:41 -07:00
Roland Bracewell Shoemaker 96a57434eb Make boulder-publisher work as a gRPC service (#1708) 2016-05-13 16:32:18 -07:00
Jacob Hoffman-Andrews e5e4fb744a * Delete Policy DB.This is no longer needed now that we have a JSON policy file.* Fix tests.* Revert Dockerfile.* Fix create_db* Simplify user addition.* Fix tests.* Fix tests* Review fixes.https://github.com/letsencrypt/boulder/pull/1773
* Delete Policy DB.

This is no longer needed now that we have a JSON policy file.

* Fix tests.
* Revert Dockerfile.
* Fix create_db
* Simplify user addition.
* Fix tests.
* Fix tests
* Review fixes.

https://github.com/letsencrypt/boulder/pull/1773
2016-04-29 12:12:24 -07:00
Kane York dc15f6a55e Readd timing stats for VA (#1759)
* Fix newVARPC sanity check logic error

* Redo style of sanity check in RA to match VA

* Switch to ServerInternal(), readd log.Info

* Add tests to make sure correct metric measured

* comments on exported symbols

* review fixes

* build an array instead of storing last
2016-04-27 11:57:21 -07:00
Kane York b7cf618f5d context.Context as the first parameter of all RPC calls (#1741)
Change core/interfaces to put context.Context as the first parameter of all RPC calls in preparation for gRPC.
2016-04-19 11:34:36 -07:00
Jacob Hoffman-Andrews e6c17e1717 Switch to new vendor style (#1747)
* Switch to new vendor style.

* Fix metrics generate command.

* Fix miekg/dns types_generate.

* Use generated copies of files.

* Update miekg to latest.

Fixes a problem with `go generate`.

* Set GO15VENDOREXPERIMENT.

* Build in letsencrypt/boulder.

* fix travis more.

* Exclude vendor instead of godeps.

* Replace some ...

* Fix unformatted cmd

* Fix errcheck for vendorexp

* Add GO15VENDOREXPERIMENT to Makefile.

* Temp disable errcheck.

* Restore master fetch.

* Restore errcheck.

* Build with 1.6 also.

* Match statsd.*"

* Skip errcheck unles Go1.6.

* Add other ignorepkg.

* Fix errcheck.

* move errcheck

* Remove go1.6 requirement.

* Put godep-restore with errcheck.

* Remove go1.6 dep.

* Revert master fetch revert.

* Remove -r flag from godep save.

* Set GO15VENDOREXPERIMENT in Dockerfile and remove _worskpace.

* Fix Godep version.
2016-04-18 12:51:36 -07:00
Kane York 25b45a45ec Errcheck errors fixed (#1677)
* Fix all errcheck errors
* Add errcheck to test.sh
* Add a new sa.Rollback method to make handling errors in rollbacks easier.
This also causes a behavior change in the VA. If a HTTP connection is
abruptly closed after serving the headers for a non-200 response, the
reported error will be the read failure instead of the non-200.
2016-04-12 16:54:01 -07:00
Jacob Hoffman-Andrews ecc04e8e61 Refactor log package (#1717)
- Remove error signatures from log methods. This means fewer places where errcheck will show ignored errors.
- Pull in latest cfssl to be compatible with errorless log messages.
- Reduce the number of message priorities we support to just those we actually use.
- AuditNotice -> AuditInfo
- Remove InfoObject (only one use, switched to Info)
- Remove EmergencyExit and related functions in favor of panic
- Remove SyslogWriter / AuditLogger separate types in favor of a single interface, Logger, that has all the logging methods on it.
- Merge mock log into logger. This allows us to unexport the internals but still override them in the mock.
- Shorten names to be compatible with Go style: New, Set, Get, Logger, NewMock, etc.
- Use a shorter log format for stdout logs.
- Remove "... Starting" log messages. We have better information in the "Versions" message logged at startup.

Motivation: The AuditLogger / SyslogWriter distinction was confusing and exposed internals only necessary for tests. Some components accepted one type and some accepted the other. This made it hard to consistently use mock loggers in tests. Also, the unnecessarily fat interface for AuditLogger made it hard to meaningfully mock out.
2016-04-08 16:12:20 -07:00
Jacob Hoffman-Andrews 3018c00519 Testing and logging improvements
Pass log as an argument to SA. This allows us to mock it out.
Use a mockSA in CA test.
Use mockSA in orphan-finder test.
Improve logging from assert functions: Use our own printing style plus FailNow() so that each failure message isn't prefixed by "test-tools.go:60"
Remove duplicate TraceOn.

Part of #1642.

https://github.com/letsencrypt/boulder/pull/1683
2016-04-04 18:42:42 -07:00
Jacob Hoffman-Andrews 4fb0f49be3 Replace CertificateIssuanceError
with MalformedRequestError. The distinction was not useful and was out of line
with similar errors in the CA.
2016-03-27 20:56:55 -07:00
Jacob Hoffman-Andrews a3d044f681 Add multi-issuer support to the CA.
Currently this is only supported for OCSP, not for EE cert signing.

Also clean up some things in the CA unittest.
2016-03-21 20:56:58 -07:00
Jacob Hoffman-Andrews 9c194f52d4 Clean up old TODO. 2016-03-21 17:29:50 -07:00
Jacob Hoffman-Andrews cf1860797a Add more detailed logging to the CA. 2016-03-08 10:08:32 -08:00
Jacob Hoffman-Andrews 8f0f261048 When multiple names are forbidden, list all.
Also, change "name is blacklisted" in PA to "Policy forbids issuance," to match
CA.
2016-03-05 14:29:05 -08:00
Roland Shoemaker b91a152148 Simplfy backoff + collect stats on cfssl and pkcs11 errors 2016-03-02 15:54:54 -08:00
Roland Shoemaker c4dd3506aa Remove CA HSM lockout and make the OCSP updater CA backoff more HSM specific 2016-03-01 14:22:12 -08:00
Kane York db8bea7b05 Specify severity of all log.Audit calls
Fixes #1534
2016-02-25 10:55:01 -08:00
Jacob Hoffman-Andrews 9dcd6e3e3e Add config flag to enable must staple.
This ensures we don't try to pass the must staple extension to CFSSL until we've
also enabled it in AllowedExtensions in our CFSSL profile.
2016-02-19 14:52:23 -08:00
Jessica Frazelle 7955e268c7
go lint fixes
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2016-02-17 11:36:06 -08:00
Jessica Frazelle 3df2e942be
go fmt fixes
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2016-02-16 12:19:15 -08:00
Richard Barnes 901f65127d Actually use the duplicate must staple CSR 2016-02-16 14:44:53 -05:00
Richard Barnes 1d62ca847e Add duplicate-must-staple test CSR, and use it 2016-02-16 14:26:13 -05:00
Richard Barnes 4f81e8cfbd Test proper duplicate extension handling 2016-02-16 14:03:42 -05:00
Richard Barnes edd247119f Actually check for duplicate extensions 2016-02-16 13:50:07 -05:00
Richard Barnes 42782beccf Clean up metrics and don't use naked returns 2016-02-16 13:34:03 -05:00
Richard Barnes 4e31d8068e Merge branch 'master' into must-staple 2016-02-16 13:25:05 -05:00
Richard Barnes 5d35967c26 Ignore duplicate extensions 2016-02-16 13:23:37 -05:00
Jeff Hodges 1498381e76 issue without a CommonName if not given one
It's behind a new temporary config flag.

Also, check if the CN is over 64 bytes.

This also makes sure the certificate's Subject is not empty if the CN is
empty by always setting the SerialNumber in Subject.

While I was here, I also corrected the logged hex encoding of
SerialNumber so that its prefixed by zeroes correctly. See the use of
core.SerialToString in IssueCertificate.

I also added a test for the no CommonName and no SANs case.

Fixes #40
2016-02-12 11:49:16 -08:00
Jeff Hodges ce9283d3c6 in ca tests, tell cfssl we are making serials
Also in ra tests.

This fixes the spurious ca and ra test failure where the serials are the
wrong size. CFSSL makes ones that are larger than we expect.
2016-02-09 14:10:28 -08:00
Richard Barnes 06ac584b8e Printf clean-up 2016-01-27 08:58:19 -05:00
Richard Barnes 4c3f14bb9c Merge branch 'master' into must-staple 2016-01-27 08:57:12 -05:00
Roland Shoemaker 29127d5779 Add tool to find orphaned certificates in boulder-ca logs 2016-01-26 15:43:23 -08:00
Richard Barnes 14fbf3b4d3 Add stats and error only on a bad TLS Feature extension 2016-01-25 18:46:58 -05:00
Richard Barnes 65ea6f6449 Stricter error checking for extensions 2016-01-22 15:30:45 -05:00
Richard Barnes 3411e9d7d7 Merge branch 'master' into must-staple 2016-01-22 14:54:09 -05:00
Hugo Landau f49028107e Allow CFSSL profiles to be selected by key type
Allows multiple CFSSL profiles to be defined. A profile is selected by
key type. ECDSA keys get one profile, RSA keys get another.

Either the "profile" config option or the "rsaProfile" and
"ecdsaProfile" config options must be specified. Both cannot be
specified. Specifying "profile" uses the same profile for RSA and ECDSA.

Fixes #1384
2016-01-22 11:00:41 +00:00
Richard Barnes e3daa6cde5 Factor out extension handling and require a specific value 2016-01-12 16:23:09 -08:00
Richard Barnes 02595e0b8e Merge branch 'master' into must-staple 2016-01-12 16:02:01 -08:00
Damian Duesentrieb ad742c01d9 Updated call to NewCertificateAuthorityImpl 2016-01-08 14:30:22 +01:00
Damian Duesentrieb 491a76a6f6 Merge remote-tracking branch 'upstream/master' into test_wrong_signature 2016-01-08 14:08:37 +01:00
Hugo Landau f218e314f8 Add good key testing for ECDSA. 2016-01-07 22:48:38 +00:00
Jeff Hodges f6473efcc2 delete ca.RevokeCertificate
Also, delete the unused core.CertificateAuthorityDatabase while we're
here.

Fixes #1319
2016-01-04 23:59:21 -08:00
Richard Barnes a439df40ca Address review comments 2015-12-16 09:00:04 -06:00
Richard Barnes dfc7021bd2 Add new test files 2015-12-15 15:16:03 -05:00
Richard Barnes b48d3a304b Provide correct TLS-Feature extension value 2015-12-15 14:58:37 -05:00
Richard Barnes b4f202fd38 Add changes to CA tests 2015-12-15 14:56:39 -05:00
Richard Barnes 02a98e8097 Add support for the must-staple extension 2015-12-04 16:17:04 -05:00
Damian Düsentrieb 1ce57b6f60 Merge branch 'master' into test_wrong_signature 2015-12-02 17:59:13 +01:00
Damian Düsentrieb c6a55136b1 Merge branch 'master' into test_wrong_signature 2015-11-30 12:24:35 +01:00
Jacob Hoffman-Andrews 3ede9b7223 Allow PKCS11 config to be loaded from a file.
This allows secret values (PIN) to be separated from the main config.

Part of #1157.

In the process, move the CA constructor in the direction of
https://github.com/letsencrypt/boulder/wiki/Config-plan:

- Make most fields private.
- Take private key and issuer cert as constructor arguments rather than
  constructing them internally.

This allows the CA test to parse the private key and issuer cert once, rather
than once per test case.
2015-11-27 15:23:31 -08:00
Roland Shoemaker 22c472f556 Remove pointless ParseCertificate 2015-11-22 16:29:10 -08:00
Damian Duesentrieb 1da2f70321 using t.Fatalf instead of AssertError 2015-11-22 16:59:43 +01:00
Damian Duesentrieb e3d8566844 Added test: CA must reject CSRs with invalid signatures. 2015-11-20 21:18:45 +01:00
Richard Barnes d8c67285cf Enable configuration of supported challenges 2015-10-31 16:55:59 +09:00
Richard Barnes a79020c1d0 Further consolidation 2015-10-21 22:09:44 -04:00
Richard Barnes 8cf950e515 Fix go vet error 2015-10-21 21:36:07 -04:00
Richard Barnes f820d9f29c Address @jsha comments 2015-10-21 21:32:02 -04:00
Richard Barnes 673c0e9799 Merge branch 'master' into hsm-fault 2015-10-21 17:34:03 -04:00
Richard Barnes 288945217e Allow configuration of the HSM timeout 2015-10-21 17:33:19 -04:00
Richard Barnes 128b784805 Add stats to CA 2015-10-21 17:00:06 -04:00
Richard Barnes 3637dfb0c1 ServiceUnavailableError 2015-10-21 16:25:43 -04:00
Richard Barnes 55b4fb116e Remove adaptation from rate limit 2015-10-21 16:04:36 -04:00
Richard Barnes 06a743882c Treat all signer errors as HSM errors 2015-10-21 15:24:45 -04:00
Richard Barnes 28be8023cf Add a mock OCSP signer and better OCSP HSM fault tests 2015-10-21 13:34:43 -04:00
Richard Barnes be7c7aebbb Address @jcjones comments 2015-10-21 12:29:42 -04:00
Richard Barnes 305b44bd16 Consistent HSM fault checking 2015-10-21 10:49:30 -04:00
Richard Barnes d0e12c357a Move checkHSMFault together with noteHSMFault 2015-10-21 10:48:30 -04:00
Richard Barnes d1d1690f2a Have the CA recognize and persist HSM faults 2015-10-21 10:46:22 -04:00
Jessica Frazelle 3ce50c106b
Add test/vars package
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2015-10-20 22:29:34 -07: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
Roland Shoemaker 45ec69951a Revert removal of ca.RevokeCertificate 2015-10-13 15:38:11 -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 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
Jeff Hodges 0df44e5d90 clean up CSRs with capitalized letters
This change lowercases domains before they are stored in the database
and makes policy.WillingToIssue reject any domains with uppercase
letters.

Fixes #927.
2015-10-08 17:04:07 -07:00
bifurcation 90050e91f5 Merge branch 'master' into golint 2015-10-05 19:23:24 -04:00
Jeff Hodges 5217af94b0 allow whitelisting by a specific reg id
Currently, the whitelisted registration ID is one that is impossible for the
database to return. Once the partner's registration is in place, we can
deploy a change to it.

Fixes #810
2015-10-05 14:11:38 -07:00
bifurcation e7f47d4f09 Merge branch 'master' into golint 2015-10-05 00:14:29 -04:00
Richard Barnes 498deeb518 Fix golint in ./mocks 2015-10-04 20:37:06 -04:00
Jeff Hodges b5e989ec49 read fully from urandom in the ca
This didn't cause any certificates to be made with duplicate serial
numbers because the primary key in the certificates table is the serial
number and so attempts to insert duplicates fail.

The cause is the use of rand/Reader.Read. rand/Reader.Read does not
perform the io.ReadFull that rand.Read does. Without the io.ReadFull,
less than all of the random part of the serial number would be filled
in.

Fixes #911.
2015-10-03 19:17:40 -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 1975e417e0 Update CFSSL.
This pulls in a few cfssl upstream fixes:

cloudflare/cfssl#347: Fix CKA_ALWAYS_AUTHENTICATE check
cloudflare/cfssl#344: Allow client to specify full serial.
cloudflare/cfssl#340: OCSP doesn't include CA when unnecessary.

This also updates boulder-ca to use the new full-serial API in CFSSL.

I have run tests for cfssl and they pass:

cd ~/go/packages/src/github.com/cloudflare/cfssl/
go test ./...
2015-10-01 13:45:59 -07:00
Jeff Hodges 5383ab4aa9 remove the ca database
The last step of removing the ca incremented serial number generation.

Fixes #813.
2015-09-25 13:50:44 -07:00
Jacob Hoffman-Andrews 668ccc2d97 Merge github.com:letsencrypt/boulder into longserial 2015-09-22 14:04:19 -07:00
Jacob Hoffman-Andrews 3ba3003990 Use + instead of Sprintf. 2015-09-22 13:00:06 -07:00
Jacob Hoffman-Andrews 708f0384bc Fix review comments. 2015-09-22 12:23:35 -07:00
Jacob Hoffman-Andrews f430280884 Fix review comments. 2015-09-21 18:18:08 -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
Jacob Hoffman-Andrews d05b9b833f Update cfssl to latest master.
This pulls in the pkcs11key change from
https://github.com/cloudflare/cfssl/pull/330, and updates the Boulder code to
match.

Note: This change overwrites the local changes to our vendored CFSSL made in
https://github.com/letsencrypt/boulder/pull/784. That's intentional: The
upstream changes in https://github.com/cloudflare/cfssl/pull/330 accomplish the
same thing, more cleanly.
2015-09-20 20:44:44 -07:00
Jeff Hodges 8ed4298b32 Merge branch 'master' into proper-errors 2015-09-17 21:08: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