Commit Graph

67 Commits

Author SHA1 Message Date
James Munnelly
21c7b2e13f Increase ACME control loop max back-off. Increase create order back-off to 1h. Fire Event when Order fails.
Signed-off-by: James Munnelly <james@munnelly.eu>
2019-01-10 22:07:48 +00:00
James Munnelly
0fcc0c666c Update copyright header year
Signed-off-by: James Munnelly <james@munnelly.eu>
2019-01-07 15:07:55 +00:00
James Munnelly
943e545697 Switch issuer.Issue to return a pointer and fix up setting secret fields
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-30 11:47:08 +00:00
James Munnelly
1f68b0c583 Fix up unit tests
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-29 12:11:42 +00:00
James Munnelly
e5830af6ba Fix event log format & add additional event
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-29 12:11:42 +00:00
James Munnelly
34c3590052 Store a copy of the signed certificate on the Order resource after Finalize
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-29 12:11:42 +00:00
James Munnelly
a6b7cade09 Fix up event logging and add an extra event
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-28 19:16:59 +00:00
James Munnelly
8f3589e59a Fire warning if retrieving an order's certificate fails
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-23 14:30:59 +00:00
James Munnelly
826441f698 Add more Event messages to ACME Certificate issuer
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-23 14:11:09 +00:00
James Munnelly
447ad2d2ea Fire Event when creating a new Order
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-23 14:10:37 +00:00
Max Ehrlich
bbd9249198 Configurable issuer duration and renewBefore Take 2 (#893)
* Configurable issuer duration and renewBefore [1/3]

This is part one of (probably) three parts manually moving the changes from commit 723015174a167d746323f506ab3575cfb243d8bd to the new master. This commit moves the basic functionality of configurable duration while skipping e2e tests and docs. It does not include new work.

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Configurable issuer duration and renewBefore [2/3]

This commit moves over most of the e2e testing updates, some things are intentionally left out as they may be obsolete

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Configurable issuer duration and renewBefore [3/3]

This commit moves the documentation changes, completely the migration of the original code to the latest master

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Rerunning all hack scripts with since the massive bazel update

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Add missing boilerplate headers

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Rerun codegen hack

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Rerunning update-docs hack

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix failing unit tests

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix build errors in e2e tests

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Rerun update-deps

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Don't recreate the CA issuer, it already exists

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Need to create new issuers for the duration and renew time tests because those fields are set in the issuer, so make sure they are named uniquely

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Add duration e2e tests for self-signed issuer

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Add duration e2e tests for vault w/ custom mount path

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Add validation to disallow acme certificates with duration and renewBefore set and update unit tests to verify

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Update docs to mention duration/renew for self-signed issuer and fix potential parsing errors with rst formatting

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Self-signed issuer was missing duration validation

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix a bug causing certificates with a short enough renew-before w.r.t their duration to be renewed instantly and forever

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Print the exact time until renewal

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Move duration and renwal validation to the issuer validation

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Update e2e tests to work with new validation

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Add e2e test for the self-signed issuer

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Redo cert duration and renew before to appear as part of the CSR and not the issuer

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Updating tests to match new duration/renewbefore format

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Update e2e tests to match new format

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Update docs to reflect changing the field from issuers to certificates

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Remove event firing and replace with a TODO as of discussion on PR

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Run hack scripts

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Remove the sync unit test since without events there is no way to catch the warnings that it was testing

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Use IssuerOptions RenewBeforeExpiryDuration if certificates dont set a renewBefore value for immediate renewal checks

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Delete check on certificate data length in e2e test for certificate duration as there is no reason it should be there

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Update e2e tests since certificate creation will never generate an event

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Rerunning hack scripts after big rebase

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix a few problems that slipped through during the rebase

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix an e2e error that resulted from the rebase

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Add unit test for the calculateTimeBeforeExpiry function

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Adding back in a bunch of missing error checks

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Remove unused function

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Add missing boilerplate

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Remove unused constant

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Move log constants to function body

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Rerun hack scripts

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Remove mistakenly commited file

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Remove double-import of util package

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix bad function call in e2e vault issuer

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Change duration and renewBefore to be pointer fields as they are optional

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Remove wrong vault issuer test that got passed the rebase somehow

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Change e2e to use pointer format

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Move e2e cert tests out of issuer test file

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Move e2e self-signed issuer test to new location

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Make sure to check for nil in GenerateTemplate

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Add more empty checks to be safe

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Rerunning hacks after rebase

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix bad function call in new e2e test

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Try not setting duration and renewbefore on acme e2e tests

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Zero checks should really just be replaced by nil tests, zero should be caught as any other too-small value

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fixed a missing nil check that got away

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Change e2e duration test format to use pointer times to better simulate API calls

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix sync unit test to match e2e test format

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Fix vault e2e test

Signed-off-by: Max Ehrlich <max.ehr@gmail.com>

* Revert changes to Certificate sync function

Signed-off-by: James Munnelly <james@munnelly.eu>

* Remove selfsigned e2e issuer.go

Signed-off-by: James Munnelly <james@munnelly.eu>

* Don't use ACME issuer in duration example and tidy up line endings

Signed-off-by: James Munnelly <james@munnelly.eu>

* Allow renewBefore to be set on ACME certificates

Signed-off-by: James Munnelly <james@munnelly.eu>

* Update renewBefore ACME docs. Remove unused fields.

Signed-off-by: James Munnelly <james@munnelly.eu>

* Rename calculateTimeBeforeExpiry to calculateDurationUntilRenew

Signed-off-by: James Munnelly <james@munnelly.eu>
2018-11-14 22:30:00 +00:00
James Munnelly
c1bd9c4a2e Add missing call to retryOrder in existing order value for private key check
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
965757cce0 Retry order if existing Order certificate is invalid
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
403a746bfa Always reset LastFailureTime in retryOrder
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
87a479e6cb Add extra comments in ACME Issuer function
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
f553f8e8a4 Move existing order checking into own function
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
f2551d3832 Reorder checking for existingOrder
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
e4399e87c5 Move private key generation to start of Issue
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
536b6fd76f Refactor ACME issuer generate private key code
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
374db0b458 Refactor ACME issuer cleanup orders code
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-15 23:02:17 +01:00
James Munnelly
d323a1df0d Add unit tests for acmeorders and acmechallenges
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-12 12:40:39 +01:00
James Munnelly
9214615d6e Fix race issues in ACME issue function. Add extended unit tests.
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-12 12:40:39 +01:00
James Munnelly
ad99639b44 Fix failing test
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-12 12:40:38 +01:00
James Munnelly
847d0c6152 Refactor controllers to return Response structures
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-12 12:40:38 +01:00
James Munnelly
f8b1e653f3 Refactor ACME Issuer to create and manage Order resources
Signed-off-by: James Munnelly <james@munnelly.eu>
2018-10-12 12:40:37 +01:00
Max Ehrlich
511650ca82
ACME issuers currently will not support getting the CA certificate
Signed-off-by: Max Ehrlich <max.ehr@gmail.com>
2018-09-13 17:07:14 -04:00
James Munnelly
51195e4c5f Update license header and add header to every file
Signed-off-by: James Munnelly <james.munnelly@jetstack.io>
2018-08-13 15:53:37 +01:00
James Munnelly
c169a1ffc1 Catch edge case where the CN and DNSNames on a Certificate have been reordered 2018-08-08 20:19:16 +01:00
James Munnelly
0dd3155fb2 Add logic to handle ready vs valid ACME orders 2018-08-08 13:39:34 +01:00
James Munnelly
2fcbee05b7 Update ACME issuer 2018-08-07 16:13:46 +01:00
James Munnelly
36f9f356cd Refactor ACME client construction into dedicated ACME package 2018-08-07 15:22:53 +01:00
James Munnelly
686e9159e5 Wait for ACME Orders to be in 'ready' state before attempting finalization 2018-07-25 18:05:45 +01:00
Afolabi Badmos
445e522432 Add support for EC keys
- This PR adds two fields to CertificateSpec:
  - `keyAlgorithm`, denotes which algorithm to use when generating
    a private key. Can be either `rsa` or `ecdsa`. When not set, the
    default algorithm used `rsa`.
  - `keySize`, denotes the key size of the private key being generated.
    For `rsa`, minimum key size is 2048 and maximum is 8192.
    For `ecdsa`, sizes 224, 256, 384 & 521 are supported.
    See https://golang.org/pkg/crypto/elliptic

- `keySize` can be set without being explicit about `keyAlgorithm`.
  - If `keySize` is specified and `keyAlgorithm` is not provided, `rsa` will
    be used as the key algorithm.

- `keyAlgorithm` can be set without being explicit about `keySize`.
  - If `keyAlgorithm` is specified and `keySize` is not provided, key size
    key size of `256` will be used for `ecdsa` key algorithm and
    key size of `2048` will be used for `rsa` key algorithm.

- helper functions in `pki` package now return crypto.PrivateKey
2018-07-17 12:42:07 -04:00
James Munnelly
1fd8cdf13e Create common GenerateCSR and GenerateTemplate methods for creating Certificate/CertificateRequest 2018-06-08 15:15:27 +01:00
James Munnelly
0a960d46b2 Fix bug in issue method preventing cert issuance 2018-04-12 16:50:03 +01:00
James Munnelly
70dde521a1 Set status conditions on validation success. Call WaitOrder instead of GetOrder in issue. 2018-04-11 23:30:54 +01:00
James Munnelly
1d52cbeec7 Remove unused strings and standardise event reasons 2018-04-09 21:26:38 +01:00
James Munnelly
d197817fa7 Improve error reporting and use of status conditions 2018-04-09 21:17:51 +01:00
James Munnelly
1485546ed5 Clear ACME order URL if FinalizeOrder fails with 4xx error 2018-04-09 20:02:26 +01:00
James Munnelly
4b361348ef Rewrite ACME issuer to use new ACMEOrderChallenge struct 2018-04-09 15:40:32 +01:00
James Munnelly
f2ddd1d111 Change DNSNames/CommonNameForCertificate function to not return an error 2018-04-04 23:37:37 +01:00
James Munnelly
e91dfc40af Fix ACME CSR generation 2018-03-23 18:50:46 +00:00
James Munnelly
0a0747dac7 Move OrderURL into OrderStatus struct and fix up http solver 2018-03-23 18:50:45 +00:00
James Munnelly
8542e1c3a4 Use order finalize url when finalizing 2018-03-23 18:50:45 +00:00
James Munnelly
7dc50cdea6 Rewrite acme issuer for acme v2 2018-03-23 18:50:44 +00:00
James Munnelly
fa7e052ac1 Move to github.com/jetstack/cert-manager repo 2017-11-03 16:41:39 +00:00
James Munnelly
a4a40bdf2d Fix checking for invalid data in issuer secrets 2017-10-26 22:47:17 +01:00
James Munnelly
9d933d9e11 Only update certificate status in the controller package to stop conflicts 2017-10-13 20:15:29 +01:00
James Munnelly
2600cb8e14 Fix up altName->dnsName change 2017-10-13 14:04:14 +01:00
James Munnelly
a4b1d346c7 Fix invalid check for empty certificate domains 2017-10-13 13:05:21 +01:00