Commit Graph

1045 Commits

Author SHA1 Message Date
Ying Li 4d696a0187 Grammar/spelling/formatting/readability fixes.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 12:26:48 -08:00
Ying Li 7ee1173084 Add information on how to run notary-signer.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 12:26:48 -08:00
Ying Li 2e8721564d Added documentation for the notary signer configuration file.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 12:26:48 -08:00
Ying Li e9d0e68b97 Add information on how to run notary-server from a docker image.
Also include information on how to override the configuration file
in the docker image.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 12:26:48 -08:00
Ying Li ca54b435ce Add documentation for notary server (what it does, etc.).
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 12:26:48 -08:00
Ying Li 41b1d57b95 Document the notary-server configuration JSON file.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 12:26:48 -08:00
Ying Li 351f90fa1c Add a script to use openssl to generate root/server/client ssl certs.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 12:26:48 -08:00
Ying Li 25f22a2dc8 Merge pull request #357 from mtrmac/fix-vet
Fix (make vet)
2015-12-11 11:33:24 -08:00
Miloslav Trmač da7c87f9dc Fix (make vet)
server/handlers/default_test.go:353: GetCurrent passes Lock by value: handlers.failStore contains github.com/docker/notary/server/storage.MemStorage contains sync.Mutex
tuf/store/httpstore_test.go:208: github.com/docker/notary/tuf/validation.ErrBadRoot composite literal uses unkeyed fields

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-11 19:59:16 +01:00
Ying Li 8fd8916b15 Merge pull request #352 from HuKeping/check-map
Use canonical way to check if a map contains a key
2015-12-10 23:13:27 -08:00
HuKeping 54af67344b Minor typo
Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-12-11 14:07:38 +08:00
HuKeping f147a7ac68 Use canonical way to check if a map contains a key
As the language spec:
https://golang.org/ref/spec#Index_expressions

Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-12-11 14:07:38 +08:00
Ying Li c77bbee0ef Merge pull request #351 from cyli/better-validation-errors
Propagate error validations from server to client
2015-12-10 21:29:57 -08:00
Ying Li 6aa114a49f Fix all instances where 'propagate' was mispelled as 'propogate'
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 15:12:05 -08:00
David Lawrence 26d30953c8 Merge pull request #312 from mtrmac/cert-expiration
Cert expiration
2015-12-10 08:40:24 -08:00
David Lawrence 6f221551a3 Merge pull request #311 from mtrmac/invalid-passphrase
Fix error handling on invalid root passphrase
2015-12-10 08:40:02 -08:00
Ying Li b69c200038 More coverage of the validation error serialization
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-09 17:12:14 -08:00
Ying Li 20f5b5f3b2 Ensure that the server produces errors the client can parse.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-09 16:48:09 -08:00
Ying Li 3f3110bba2 In tuf/httpstore, attempt to parse any validation errors from server.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-09 16:29:02 -08:00
Ying Li fb9afbc5d8 Server propogates validation failures in the 400 response.
Previously, it just said that the update was invalid, but not why.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-09 15:10:17 -08:00
Ying Li 3aa13e6645 Move validation errors to tuf, since that is the expected server interface.
Also make the validation errors serializable as JSON.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-09 14:04:44 -08:00
Ying Li 4208945fc1 Move the notary errors HTTP errors into the server package.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-09 11:22:49 -08:00
Ying Li 45c740b6b8 Add an invalid update error to the server errors.
This would represent a validation error on the updates, as opposed to
a malformed upload error.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-09 11:16:35 -08:00
Miloslav Trmač 06e58c1d11 Tighten TestNewCertificate tests
Using the just added facility to generate a certificate as of a specific
time, tighten TestNewCertificate to use equality comparisons.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 20:02:10 +01:00
Miloslav Trmač bd6d937f43 Fix computation of certificate expiration
Instead of 3650 days, actually use 10 years (i.e. take into account leap
days).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 20:02:10 +01:00
Miloslav Trmač 3c6335c572 Explicitly supply validity times to certificate generation
Add explicit startTime and endTime parameters to
cryptoservice.GenerateCertificate and trustmanager.NewCertificate.

trustmanager.NewCertificate as a low-level data manipulation function
should not be hard-coding policy (10-year expiration); that policy
belongs to its callers, or one more level higher to callers of
cryptoservice.GenerateCertificate.

These places hard-coding policy now also have an explict comment to
that effect.

In addition to conceptual cleanliness, this will allow writing tests
of certificate expiry by generating appropriate expired or nearly-expired
certificates.

Tests which don't care about the policy much will continue to use the
just added cryptoservice.GenerateTestingCertificate.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 20:02:10 +01:00
Miloslav Trmač d5c080ae9c Add cryptoservice.GenerateTestingCertificate
Various tests have been calling trustmanager.NewCertificate and
open-coding most of cryptoservice.GenerateCertificate.  So, add
cryptoservice.GenerateTestingCertificate.  It differs only by using
crypto.Signer instead of data.PrivateKey because the tests
have a crypto.Signer more frequently available, and converting
from data.PrivateKey to crypto.Signer is easier than the other way.

This will make it easier to add policy parameters which the tests don't
care about to trustmanager.NewCertificate and
cryptoservice.GenerateCertificate in the future.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 20:02:10 +01:00
Miloslav Trmač 74d327f273 Remove an incorrect comment.
The commented code is not converting DER to PEM, it is parsing DER into
an in-memory data structure, and is hopefully just as clear without a
comment.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 20:02:10 +01:00
Miloslav Trmač e19e7fc44d Remove misleading passphrase-related error handling in NotaryRepository.Initialize:
1. It is on a path where those errors can never happen
2. The specific error handling would silently ignore the error, which
   can’t be right anyway.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 19:58:02 +01:00
Miloslav Trmač 57a15112c8 Fix error handling on invalid root passphrase
When the user insists on an invalid passphrase (or aborts the
operation), CryptoService.GetPrivateKey will try the correct root
location first, correctly failing, and then try to look for the root key
in the $gun subdirectory, and so will return the last error, a confusing
”open $path: no such file or directory”.

So, recognize the passphrase-related errors and fail with them directly.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 19:58:02 +01:00
Miloslav Trmač d3c3d70d6d Add gun to CryptoServiceTester
The gun field is not necessary yet, but will be useful in a future
commit. But including it immediately allows us to simplify by using
an ordinary method for cryptoServiceFactory instead of closures.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2015-12-09 19:45:34 +01:00
David Lawrence 2bfadacf34 Merge pull request #341 from HuKeping/parse-viper
Add a function to parse viper
2015-12-08 17:31:55 -08:00
HuKeping 639f1e80f0 Use the function to parse viper on server side
Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-12-09 09:17:25 +08:00
HuKeping bfe7316de9 Add a function to parse viper
None of these `filename`, `ext` or `configPath` should be in `main`,
they are all just for creating a instance of Viper and then nothing.
Do it in a separate function will make the function `main` more readable.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-12-09 09:17:24 +08:00
Diogo Mónica a3d2974e1b Merge pull request #344 from cyli/client-new-repo-refactor
Minor refactor of NotaryRepository constructor to use more shared code.
2015-12-08 15:11:09 -08:00
Ying Li 9ef782184c Minor refactor of NotaryRepository constructor to use more shared code.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-07 17:19:28 -08:00
David Lawrence 5f1100a3bf Merge pull request #343 from endophage/fix_340
fixing incomplete comment as raised in #340
2015-12-07 16:37:55 -08:00
Ying Li d9419287ea Merge pull request #339 from cyli/server-handler
Get Snapshot Key Handler
2015-12-07 16:22:15 -08:00
David Lawrence 4261d28d46 fixing incomplete comment as raised in #340
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-07 16:12:09 -08:00
Ying Li d59ae2d90f Add the handler for GET-ting a snapshot key.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-07 15:13:58 -08:00
Ying Li bf0c6d0844 Fix bug with ED25519 cryptoservice's ListKeys
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-07 15:01:40 -08:00
David Lawrence dd69872bb6 Merge pull request #332 from endophage/server_snapshot
Server snapshot
2015-12-07 14:56:07 -08:00
David Lawrence eb75898c43 fix roleExpired varname, it shadowed a func name
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-07 14:44:11 -08:00
David Lawrence 3e96684ba1 Merge pull request #338 from cyli/keydbstore-error
KeyDBStore refactor so that it just directly takes the DB arguments.
2015-12-07 14:33:01 -08:00
David Lawrence fb76bca9f0 adding comment to snapshot key insert race condition test per @cyli's request
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-07 12:55:09 -08:00
David Lawrence 09a6fa07a1 some tests for the handlers
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-07 12:55:09 -08:00
David Lawrence 91c9b61edb update GetHandler to use new snapshot code
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-07 12:55:09 -08:00
David Lawrence 844c1872c4 adding tests for server/snapshot/snapshot.go
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-07 12:55:09 -08:00
David Lawrence b0c7ef5b88 addressing @cyli's comments
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-07 12:55:09 -08:00
David Lawrence cae5940c70 generate snapshots server side
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-12-07 12:55:09 -08:00