Commit Graph
24 Commits
Author SHA1 Message Date
Nic Klaassen fbed5c9684 test: add GCP KMS unit tests (#18245) 2022-11-29 00:16:59 +00:00
Nic Klaassen 962e5a25bc plumb context to keystore methods (#18034)
* plumb context to keystore methods

Contexts are more relevant now with the GCP KMS keystore which makes
http requests, this commit makes sure they are passed everywhere they
are needed, with only a few `context.TODO`s sprinkled in.
2022-11-10 18:57:17 -08:00
Nic Klaassen bfbb71734d feat: add GCP KMS support for Teleport CA key material (#17933)
* feat: add GCP KMS support for Teleport CA key material

This commit implements support for GCP KMS as a backend for CA
operations in Teleport.

This is able to take advantage of much of the infrastucture that we have
already created for HSM support, and simply appears as a new backend for
the private key material.

The necessary configuration parameters include only the name of the KMS
keyring to use, and the protection level (which can be HSM or SOFTWARE).
These are configured in the teleport.yaml directly, in a new section
under the existing `ca_key_params` used for HSM configuration.

The GCP credentials are expected to be provided to the Teleport auth
server via the
[Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).
This means that it "just works" if the auth server is running on a GCP
compute instance with the correct attached role, and you can run tests
locally by authenticating with `gcloud auth login`.

This does not support Teleport Cloud, as our current HSM support does
not, because the Auth server needs the configuration and the access to
the GCP account. That would be a larger effort probably requiring a new
Teleport service.
2022-11-11 00:03:49 +00:00
Nic Klaassen 46f0265546 cleanup: shrink/remove keystore interface (#17908)
* shrink/remove keystore interface

This commit introduces the keystore.Manager type to handle all
interaction between CA and the keystore backends.

Why:

* reduces the code that needs to be implemented per keystore backend to
  only the necessary operations
* separate concerns of managing key material and handling CA data
  structures
* define interfaces where they're used, not implemented
* delete net 245 lines of code
* reduce keystore.KeyStore stutter
2022-11-09 01:44:22 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Nic Klaassen 847f13a8a9 refactor keystore config (#17907) 2022-10-28 11:30:49 -07:00
Nic Klaassen 1e2e978454 cleanup: renames in keystore package (#17906)
* rename raw keystore to software keystore

* mv raw.go -> software.go

* rename hsm keystore to pkcs11 keystore

* mv hsm.go -> pkcs11.go

* move keystore test into keystore package

* unexport KeyStore methods used only locally
2022-10-28 17:44:57 +00:00
Alan Parra a75fcc21d8 Update golangci-lint to 1.49.0 (#16507)
Update metalinter, fix a few lint warnings and replace deprecated linters.

`deadcode`, `structcheck` and `varcheck` are abandoned and now replaced by [`unused`][1].

Since 1.19, `go fmt` reformats godocs according to https://go.dev/doc/comment. I've done a bulk-reformatting of the codebase to keep the linter happy. Backporting is mostly harmless (the exception being `lib/services/role_test.go`, that for some reason breaks the _old_ linter using the new format).

[1]: https://golangci-lint.run/usage/linters/

* Bump golangci-lint version
* Replace abandoned linters
* Fix bodyclose on lib/auth/github.com
* Fix bodyclose on lib/kube/proxy/streamproto/proto_test.go
* Fix bodyclose on lib/srv/alpnproxy/proxy_test.go
* Fix bodyclose on lib/web/conn_upgrade_test.go
* Silence staticcheck on lib/kube/proxy/forwarder_test.go
* Silence staticcheck on lib/utils/certs_test.go
* Address BuildNameToCertificate deprecation warnings
* Run `go fmt ./...`
* Run `go fmt ./...` on api/
* Ignore formatting in role_test.go
* Remove redundant initializers in lib/srv/uacc/
* Update e/
2022-09-19 22:38:59 +00:00
Nic Klaassen 77a90c1f8e improve HSM test reliability (#13504) 2022-06-15 18:30:13 +00:00
Marco André Dinis 2493448cbd Bump x/crypto to 20220518 and remove custom algorithm signer (#12674)
This commit upgrades the version of x/crypto we use, to the current latest
`go get -u golang.org/x/crypto`

We also replaced the deprecated variables and updated the tests to match the
current default KEX Algos

The x/crypto didn't support RSA-SHA2 algos, so we developed our own algorithm
signer. This is no longer the case, and after upgrading x/crypto to 20220518 we
can safely remove the custom code we have.


From OpenSSH 8.8+, it works if we explicitly add the older algorithm
Somthing like this: `./ssh -vvv -oPubkeyAcceptedAlgorithms=+ssh-rsa-cert-v01@openssh.com teleportadmin@moon.marco.mydemo`
2022-05-25 14:47:00 +01:00
Noah StrideandSTeve Huang 2f1675e480 Run HSM integration tests in parallel (#12470)
* run HSM tests in parallel

* add missing punctuation to commit

Co-authored-by: STeve (Xin) Huang <xin.huang@goteleport.com>

Co-authored-by: STeve (Xin) Huang <xin.huang@goteleport.com>
2022-05-19 13:41:34 +00:00
Jakub NyckowskiandJim Bishopp 1f7a934584 Use new TLS key to sign DB cert during rotation (#11879)
Why
---
Current CA rotation require you to rotate the key 3 times
* `init` - to add new CA to the DB
* `update_clients` - to generate new client certificate and add it to DB 
* `standby` to remove the old CA from DB.

If any of the steps is skipped the integration will stop working as either Teleport or DB are not able to authenticate the connection.

Solution
---
Signing the client certificate with the new CA will allow to reduce the number of certificate updates and potencial DB restarts/reloads that should make the procedure simpler and less error prone. From now on the certificate will only need to be updated on `init` phase and after `standby` to remove the old CA.

Co-authored-by: Jim Bishopp <jamesbishopp@gmail.com>
2022-05-10 20:18:43 +00:00
Joel 99116409d4 Remove needlessly complex key generation scheme (#12113) 2022-04-25 09:26:10 +00:00
Jim Bishopp 22e043c430 Add TestModules (#10369)
Allows tests to set fake values to be returned from modules.GetModules()
2022-02-15 21:54:40 +00:00
Zac Bergquist 53562aadb0 Use t.Setenv in tests (#9154)
This new feature in Go 1.17 automatically restores the environment
variable to its previous value when a test ends, making it simpler
to set up the environment for tests and less likely that we accidentally
leave behind global state.

Also convert some of the remaining uses of check to standard Go tests.
2021-12-01 10:43:12 -07:00
Nic Klaassen 99cc8eb5ef Require enterprise license for HSM support (#8370) 2021-09-27 10:40:47 -07:00
Roman Tkachenko e1c3f80aa0 Fixes for cert checker and Postgres config builder (#8251) 2021-09-17 13:28:40 -07:00
Alan Parra dba49bfad6 Lint and fix missing license headers (#8075)
Introduce new make targets to check and add license headers to files
("make lint-license" and "make fix-license"). License checking is now a part of
"make lint" as well.

Initial attempts used goheader, but it caused "make lint-go" to become about 9x
slower (if not more), plus it only targets go files. Google's addlicense is fast
enough and targets however many file types we want.

Existing files that were missing licenses got the header added, using the
current year as the license date.

* Introduce lint-license and fix-license make targets
* Ignore generated files
* Add license to go files
* Replace irregular licenses with standard copyright/license
* Add license to proto files
* Install addlicense in build.assets Dockerfile
2021-08-30 09:44:09 -07:00
Nic Klaassen c48ee9f062 Add support for HSM CA rotation (#7862) 2021-08-18 21:21:43 -07:00
Nic Klaassen c9fda499de Add support for multiple CA pins (#7905) 2021-08-18 20:13:20 -07:00
Brian Joerger 9b8b9d6d0c rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Nic Klaassen 185e5fda35 Add hsmKeyStore implementation (#7614) 2021-07-29 13:08:01 -07:00
Brian Joerger c040aca4c1 Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Nic Klaassen f432a71a13 Add KeyStore interface with rawKeyStore implementation (#7613) 2021-07-27 07:57:19 -07:00