-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openssl_certificate, fixed has_expired to check the cert expiration date #53168
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8ba57b7
has_expired now does what's supposed to
Shaps 9be4df6
Added tests for expired certificate
Shaps 4da13c9
Added changelog fragment
Shaps e260b9b
simplified has_expired if logic, removed reference to self.cert.has_e…
Shaps d67b07c
Removed unnecessary assert in has_expired test
Shaps 19a327c
Now really simplified has_expired test..
Shaps 09d577d
Better formatting for changelog, added comment in _validate_has_expired
Shaps 0891eda
Better task name for expired cert test
Shaps 765bb34
clarify which PyOpenSSL version we're talking about
felixfontein File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- openssl_certificate - ``has_expired`` correctly checks if the certificate is expired or not |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
test/integration/targets/openssl_certificate/tasks/expired.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
- name: Generate privatekey | ||
openssl_privatekey: | ||
path: '{{ output_dir }}/has_expired_privatekey.pem' | ||
|
||
- name: Generate CSR | ||
openssl_csr: | ||
path: '{{ output_dir }}/has_expired_csr.csr' | ||
privatekey_path: '{{ output_dir }}/has_expired_privatekey.pem' | ||
subject: | ||
commonName: www.example.com | ||
|
||
- name: Generate expired selfsigned certificate | ||
openssl_certificate: | ||
path: '{{ output_dir }}/has_expired_cert.pem' | ||
csr_path: '{{ output_dir }}/has_expired_csr.csr' | ||
privatekey_path: '{{ output_dir }}/has_expired_privatekey.pem' | ||
provider: selfsigned | ||
selfsigned_digest: sha256 | ||
selfsigned_not_after: "-1s" | ||
|
||
- name: "Check task fails because cert is expired (has_expired: false)" | ||
openssl_certificate: | ||
provider: assertonly | ||
path: "{{ output_dir }}/has_expired_cert.pem" | ||
has_expired: false | ||
ignore_errors: true | ||
register: expired_cert_check | ||
|
||
- name: Ensure previous task failed | ||
assert: | ||
that: expired_cert_check is failed | ||
|
||
- name: "Check expired cert check is ignored (has_expired: true)" | ||
openssl_certificate: | ||
provider: assertonly | ||
path: "{{ output_dir }}/has_expired_cert.pem" | ||
has_expired: true | ||
register: expired_cert_skip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
--- | ||
- block: | ||
|
||
- import_tasks: expired.yml | ||
|
||
- import_tasks: selfsigned.yml | ||
|
||
- import_tasks: ownca.yml | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment here that this is similar to the PyOpenSSL code for
cert.has_expired()
, but that older versions have a buggy implementation and we thus do it manually here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments, hopefully makes sense :)