34 Commits
Author SHA1 Message Date
Adrien FerrandandJoona Hoikkala 889aeb31df Validate OCSP responses in case an explicit responder is designated (#7054)
* Validate OCSP response for responders that are not the certificate's issuer.

* Improve OCSP tests using a issuer/responder pair for OCSP responses

* Clean code

* Update ocsp_test.py

* Add various comments

* Add several cases of ocsp responder. More factories for the resilience tests.

* Update ocsp_test.py
2019-06-03 22:55:26 +03:00
Adrien Ferrand 04152c21b5 Update to Pylint 1.9.4 and corrections 2019-04-09 09:22:19 +02:00
Adrien FerrandandBrad Warren cac4be7046 Calculate timedelta with thisUpdate/nextUpdate in UTC (#6838)
Fixes #6836.

OCSP responses contains a thisUpdate and nextUpdate that allow to calculate its validity. Certbot currently uses datetime.now() to get the current time when OCSP check is done through cryptography. But datetime.now() expresses the date in the machine local time, and comparison operators on datetime do not take into account the offset between two datetime objects expressed in difference timezones.

As a consequence, a given thisUpdate may be seen as a future date depending on the local time, failing the OCSP check process.

The error is not critical for certbot, as it will just make some valid OCSP responses giving an EXPIRED status been ignored.

This PR fixes this comparison by taking the current time in UTC using datetime.utctime().
2019-03-11 15:27:33 -07:00
Adrien FerrandandGitHub 9c405a3cd1 Fix cryptography OCSP support (#6751)
* Reenabling OCSP cryptography support

* Refactor the validation logic of OCSP response to match the OpenSSL one

* Prepare runtime for OCSP response test

* Move unrelated test to another relevant place

* Reimplement OCSP status checks in integration tests

* Clean script

* Protect OCSP check against connection errors

* Update tests/certbot-boulder-integration.sh

Co-Authored-By: adferrand <adferrand@users.noreply.github.com>

* Cleaning

* Add a specific script for letsencrypt-auto install+help

* Remove inconsistent assertion

* Add executable permissions

* Remove unused variable

* Move testdata

* Corrected cleanup code

* Empty commit
2019-02-28 00:16:52 +01:00
Brad WarrenandGitHub ab79d1d44a Revert "Use built-in support for OCSP in cryptography >= 2.5 (#6603) (#6747)
I think this is causing failures in some of our tests so this PR reverts the change until we can fix the problem.

The 2nd commit is to keep the change using more idiomatic wording in the changelog for another change that got included in this PR.

* Revert "Use built-in support for OCSP in cryptography >= 2.5 (#6603)"

This reverts commit 2ddaf3db04.

* keep changelog correction
2019-02-06 16:36:32 -08:00
Adrien FerrandandBrad Warren 2ddaf3db04 Use built-in support for OCSP in cryptography >= 2.5 (#6603)
In response to #6594. [Fixes #6594.]

To execute OCSP requests, certbot relies currently on a openssl binary execution. If openssl is not present in the PATH, the OCSP check will be silently ignored. Since version 2.4, cryptography has support for OCSP requests, without the need to have openssl binary available locally.

This PR takes advantage of it, and will use the built-in support of OCSP in cryptography for versions >= 2.4. Otherwise, fallback is done do a direct call to openssl binary, allowing oldest requirements to still work with legacy cryptography versions.

Update: requirement is now cryptography >= 2.5, to avoid to rely on a private method from cryptography.

* Implement logic using cryptography

* Working OSCP using pure cryptography

* Fix openssl usage in unit tests

* Reduce verbosity

* Add tests

* Improve naive skipIf

* Test resiliency

* Update ocsp.py

* Validate OCSP response. Unify OCSP URL get

* Improve resiliency checks, correct lint/mypy

* Improve hash selection

* Fix warnings when calling openssl bin

* Load OCSP tests assets as vectors.

* Update ocsp.py

* Protect against invalid ocsp response.

* Add checks to OCSP response

* Add more control on ocsp response

* Be lenient about assertion that next_update must be in the future, similarly to openssl.

* Construct a more advanced OCSP response mock to trigger more logic in ocsp module.

* Add test

* Refactor signature process to use crypto_util

* Fallback for cryptography 2.4

* Avoid a collision with a meteor.

* Correct method signature documentation

* Relax OCSP update interval

* Trigger built-in ocsp logic from cryptography with 2.5+

* Update pinned version of cryptography

* Update certbot/ocsp.py

Co-Authored-By: adferrand <adferrand@users.noreply.github.com>

* Update ocsp.py

* Update ocsp_test.py

* Update CHANGELOG.md

* Update CHANGELOG.md
2019-02-05 10:45:15 -08:00
Erica Portnoy 1eabb4bae3 warn-->warning 2018-10-31 18:11:43 -07:00
Damien TournoudandBrad Warren 44a6ec29c5 Fix direct usages of the root logger (#4236)
Some code uses `logging.debug` and `logging.info` instead of
the file-specific logger in `logger.debug` and `logger.info`.
2017-02-27 18:13:06 -08:00
Peter Eckersley e05d537ff5 Avoid code repetition 2017-01-05 12:16:03 -08:00
Peter Eckersley 707b27418f Explicitly handle "unknown" responses from openssl 2017-01-05 12:06:51 -08:00
Peter Eckersley abd062cb94 Handle warnings in "revoked" responses too 2017-01-05 11:55:19 -08:00
Peter Eckersley b1be49c14f Openssl black magic
* With _some_ versions of openssl, when checking OCSP for staging certs
   only, we need this -trust_other flag
2017-01-05 11:04:01 -08:00
Peter Eckersley 4d312d8ffe Better logging 2017-01-05 11:03:53 -08:00
Peter Eckersley c29878ace9 lint 2016-12-23 01:03:38 -08:00
Peter Eckersley c5bda903f2 Another instance of overlogging 2016-12-23 00:42:17 -08:00
Peter Eckersley 2fdbb8430a Don't log errors twice
- They're already being logged down in util.run_script
2016-12-23 00:40:10 -08:00
Peter Eckersley 97081452e9 fixup 2016-12-22 18:52:20 -08:00
Peter Eckersley 0011a3b7d8 Start handling some weirder OCSP states 2016-12-22 18:51:17 -08:00
Peter Eckersley 9aa93c05c1 Simplify the ocsp_revoked() return type
- we weren't reacting to None, so call it False instead
2016-12-22 15:35:29 -08:00
Peter Eckersley 0ed3213989 Remove --check-ocsp flag
- Might have been occasionally useful, but simplicity
 - Add some missing tests, remove some obsolete ones
2016-12-21 14:38:26 -08:00
Peter Eckersley 76b8c53566 Tests for ocsp.py, and associated fixes 2016-12-21 14:38:26 -08:00
Peter Eckersley 509f4029bb more py3 fixes 2016-12-21 14:38:26 -08:00
Peter Eckersley 7d02b8dbd5 py3fix 2016-12-21 14:38:26 -08:00
Peter Eckersley fcf7387c3d Don't crash if openssl is missing 2016-12-21 14:38:26 -08:00
Peter Eckersley 011f6055d4 Better message 2016-12-21 14:38:26 -08:00
Peter Eckersley bf6084db61 With mixed staging/prod lineages, it might not be correct to stop OCSPing
- One lineage might fail, and a later one succeed
2016-12-21 14:38:26 -08:00
Peter Eckersley e5e5db24d7 CLI flag for controlling ocsp checking now works 2016-12-21 14:38:26 -08:00
Peter Eckersley 840c584cbd Make the OCSP checker a class
(Since it contains a reasonable amount of system state)
2016-12-21 14:38:26 -08:00
Peter Eckersley 7a18a124ce Better error handling 2016-12-21 14:38:26 -08:00
Peter Eckersley fe36e336a8 Run with both old and new versions of openssl 2016-12-21 14:38:26 -08:00
Peter Eckersley 245b84ab78 Format CLI to keep modern openssls happy
- This is somewhat ominous
2016-12-21 14:38:26 -08:00
Peter Eckersley ac02cd9cb8 ocsp checking needs -verify_other
https://community.letsencrypt.org/t/unable-to-verify-ocsp-response/7264
2016-12-21 14:38:26 -08:00
Peter Eckersley 40e29bb95f begin implementing OCSP checking for "certificates" 2016-12-21 14:38:20 -08:00
James KastenandPeter Eckersley 15d2a0ffde Import OCSP code from the historical cert_manager branch
(This is pde committing jdkasten's code)
2016-12-21 14:36:51 -08:00