Commit Graph

71 Commits

Author SHA1 Message Date
Ying Li 0bec06eb9b RemoveTarget now takes an optional variadic list of roles to remove from.
If none are provided, it defaults to the targets role, as before.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-16 13:18:40 -08:00
Ying Li 19c49cf7ce AddTarget now takes an optional variadic list of roles to add target to.
If none are provided, it defaults to the targets role, as before.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-16 13:18:40 -08:00
Ying Li 2c7e632925 Amend rotation tests to assert old keys are removed after rotation.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-14 17:44:28 -08:00
Ying Li 8521ea5b6d Convert NotaryRepository.RotateKeys to RotateKey(role, serverManages bool)
This should make it possible to delegate snapshot key management
to the server for existing repos, or switching back to user managing
snapshot keys.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-14 17:17:23 -08:00
Ying Li c0bf1a4a68 Fix semantic merge conflict.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 17:37:29 -08:00
Ying Li 9d2590ffb5 Only allow publishing if there is no snapshot.json, not if it's corrupt
or unreadable.

This also modifies tuf/store/filestore to return ErrMetaNotFound if the
metadata file does not exist.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-11 15:04:08 -08:00
Ying Li 8b9cc4c3f6 Minor review comment changes:
- add a specific error type when the server is requested to manage
  an unsupported key type
- variable name change

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 17:16:53 -08:00
Ying Li 5717258931 When publishing, if no snapshot data exists, create it and then try to sign.
This supports the case of a user intializing a repo so that the server
signs the snapshot, and then changing their minds and rotating the keys
so that they now sign the snapshot, but all before publishing a single
thing.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 16:28:20 -08:00
Ying Li a89bdaa9bf Just propogate server error if server can't sign snapshot.
The errors returned by the server aren't great right now, so it's hard
to try to be clever in synthesizing a signed.ErrNoKeys{}.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 10:16:39 -08:00
Ying Li a924ca172f When initializing a repo, create local keys before getting remote keys.
Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 10:16:39 -08:00
Ying Li 39d79d9844 NotaryRepository.Publish supports server managing snapshot keys.
When publishing, do not sign and send the snapshot metadata if the
client does not have the snapshot key.  If the server sends back
an error, then it also does not have a snapshot key and the
client should propogate the no signing key error.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 10:16:39 -08:00
Ying Li 4b46a34524 NotaryRepository.Intialize supports server managing snapshot keys.
If configured to have the server manage the snapshot key, the snapshot
key is not generated and there will be no snapshot metadata.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-10 10:16:39 -08: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
Ying Li e3cee0cdbd Refactor the client TestInitRepo test into reusable helper functions.
Also, eliminate the timestamp JSON constant and just generate a new
one for the tests.

The client test now also uses KeyFileStore and certs.Manager to
verify the keys and certs on disk, rather than directly manipulating
the files themselves.  This way, if the exact implementation of
KeyFileStore or certs.Manager changes, this test won't fail so long
as KeyFileStore and certs.Manager are self-consistent.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-12-03 17:52:22 -08:00
Ying Li dbcb56b3bf Renamed keystoremanager to certs, and KeyStoreManager to Manager.
Since it no longer depends upon KeyStore, nor does it manipulate keys
in any way.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-23 17:19:26 -05:00
Ying Li 517763a26d Merge pull request #280 from docker/remove-get-root
Remove KeyStoreManager's dependency on a KeyStore.
2015-11-13 15:51:42 -08:00
Ying Li edf0520c9b Remove KeyStoreManager's dependency on a KeyStore.
The root generation code is handled by CryptoService now.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-13 15:00:45 -08:00
Ying Li 8432f9db07 Fixes client to report problems contacting the remote server.
Currently, when listing, publishing, or getting a particular target,
if the remote server errors, the client attempts to load it from a
local cache.  However, if there is no local cache, it just returns
Metadata Not Found for listing and getting.  Have it report the
remote the original remote error instead of Metadata Not Found
locally.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-11-13 05:26:00 -08:00
Ying Li 5b6f64de4b Refactor notary client tests.
Move common code out into helper functions, and split up the bigger tests
into tests that specifically test adding targets, getting changelists,
publishing, and listing, as opposed to having two giant tests instead.

Also depend more on existing functions in the code (such as
NotaryRepository.GetChangelists and the server ServerMux), rather than
reimplementing them in the tests.

Signed-off-by: Ying Li <ying.li@docker.com>
Signed-off-by: David Lawrence <david.lawrence@docker.com>

Signed-off-by: Ying Li <ying.li@docker.com> (github: endophage)
2015-11-12 01:09:06 -08:00
Ying Li 91d54899d7 Add a GetPrivateKey method to cryptoservice so that we can future-proof
cryptoservice having multiple keystores

Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-29 16:34:40 -07:00
Ying Li b9a4175ea9 Update the client NotaryRepository to initialize with a root key ID
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-29 15:11:15 -07:00
David Lawrence f73560d839 creating concrete types for the various key ciphers
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-10-28 16:02:55 -07:00
David Lawrence daa36b43b7 Merge pull request #242 from docker/unify-root-nonroot-keystore
Unify root nonroot keystore
2015-10-28 13:14:19 -07:00
David Lawrence fa70a79ed7 go fmt was complaining about import order after my sed replacement
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-10-27 17:22:08 -07:00
David Lawrence 2833a88292 adding gotuf to notary
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-10-27 16:36:06 -07:00
Ying Li 566bd3ce67 Combine the nonRootKeyStore with the rootKeyStore, and move the abstracting
over the root keys directory from non-root keys directory from keystoremanager
to keystore, since we're eliminating keystoremanager.

Maintain the two separate directories, though, because one can't tell whether
there is an old-style separate-directories structure, or if someone has a GUN
that starts with tuf_keys.

Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-27 12:33:46 -07:00
Ying Li ed61974d10 Remove linking from the filestore
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-23 21:19:47 -07:00
Ying Li 402c704798 Remove symlinks from notary-client repo creation
Signed-off-by: Ying Li <ying.li@docker.com>
2015-10-21 14:21:10 -07:00
David Lawrence e587b0427a test for key rotation
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-10-09 22:53:57 -07:00
Ryan Cox 7bee606f43 Add support for 'notary status' command to show details about unpublished changes
Signed-off-by: Ryan Cox <ryan.a.cox@gmail.com>
2015-10-08 22:07:36 -07:00
David Lawrence f7ca3ef62e make key algorithm configurable for local development with in memory ed25519 crypto service
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-30 11:53:39 -07:00
David Lawrence 529230369a tests for changelist client helpers
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-28 11:29:46 -07:00
Aaron Lehmann 02dfdaf197 Use correct regular expression for repository names in HTTP handlers
Import github.com/docker/distribution/registry/api/v2 to share the
regexps that the registry API uses.

Remove ErrUnauthorized in errors package, since it conflicts with one
defined in v2.

Fixes #92

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-27 14:51:59 -07:00
David Lawrence 8b2888d122 latest vendored gotuf
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-21 13:57:21 -07:00
Nathan McCauley 0642da80f1 review feedback
Signed-off-by: Nathan McCauley <nathan.mccauley@docker.com>
2015-07-20 11:00:24 -07:00
Nathan McCauley de6f65b7e7 many testing fixups to support key aliasing
Signed-off-by: Nathan McCauley <nathan.mccauley@docker.com>
2015-07-20 11:00:22 -07:00
Diogo Monica 3b261e8972 Removing comments
Signed-off-by: Diogo Monica <diogo@docker.com>
2015-07-20 10:08:15 -07:00
David Lawrence c9732dd9cb stop targets dir being created, we don't use it
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-18 22:46:04 -07:00
David Lawrence 5015b1f47d fixing timestamps, clearing changelists, and the Adding target byte log
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-18 17:55:13 -07:00
David Lawrence b561f347ed updating errors to use distribution's errcode package
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-17 18:02:56 -07:00
David Lawrence d453c6548d client side of multi TUF file atomic update
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2015-07-17 17:48:06 -07:00
Aaron Lehmann afc331b930 Add a unit test for publish
This instantiates a temporary server, publishes some targets to it, and
makes sure we can pull back the correct targets from the server.

Also fixes a few problems with the client unit tests, error reporting in
the client, and logging in the server.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-17 16:27:31 -07:00
Aaron Lehmann d2ea9cc0d5 Updates to notary for gotuf's split of PublicKey and PrivateKey interfaces
Functions should now take data.PublicKey or data.PrivateKey instead of
data.Key.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-17 11:35:22 -07:00
Diogo Mónica 1a5ad474f3 Merge pull request #66 from docker/rename-certificate-stores
Rename certificate stores to trustedCertificateStore and trustedCAStore
2015-07-15 22:40:03 -07:00
Diogo Mónica 0ed6072a4a Merge pull request #67 from docker/adding-certs
Adding new certificates
2015-07-15 22:35:54 -07:00
Diogo Monica d743dfac6e Fixed config files and trust manager tests to point at new fixtures
Signed-off-by: Diogo Monica <diogo@docker.com>
2015-07-15 19:46:57 -07:00
Aaron Lehmann 36a8f77129 Rename certificate stores to trustedCertificateStore and trustedCAStore
Add convenience methods to KeyStoreManager to add certs to both cert
stores.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-15 18:10:53 -07:00
Aaron Lehmann e5a42d4df9 Add ExportKeysByGUN function
It exports the keys for a particular GUN to a zip, encrypted with a
specified passphrase.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-15 17:14:57 -07:00
Aaron Lehmann 6d3d98b873 Move non-root keys to tuf_keys subdirectory
This subdirectory is at the same level as root_keys. It avoids having
rootKeyStore and nonRootKeyStore overlap. Previously, the base directory
for rootKeyStore was .../private/root_keys and the base directory for
nonRootKeyStore was .../private.

This commit also removes deduplicating logic in ExportAllKeys, which is
no longer needed now that the stores don't overlap.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-15 17:14:57 -07:00
Aaron Lehmann a16581ecc7 Move CryptoService and UnlockedCryptoService into a cryptoservice package
Move GenRootKey and GetRootCryptoService to KeyStoreManager, now that
they don't depend on client-specific types.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-07-14 18:39:38 -07:00