Commit Graph
2125 Commits
Author SHA1 Message Date
Craig SmithandBrad Warren 6a933f1de3 Changed plugin interface return types (#3748). (#3780) 2016-12-19 18:02:05 -08:00
Peter Eckersley 6a67ce5567 Ensure that path_surgery doesn't happen until we have a logger 2016-12-19 17:00:09 -08:00
Brad WarrenandPeter Eckersley ae379568b1 Mitigate problems for people who run without -n (#3916)
* CLI flag for forcing interactivity

* add --force-interactive

* Add force_interactive error checking and tests

* Add force_interactive parameter to FileDisplay

* add _can_interact

* Add _return_default

* Add **unused_kwargs to NoninteractiveDisplay

* improve _return_default assertion

* Change IDisplay calls and write tests

* Document force_interactive in interfaces.py

* Don't force_interactive with a new prompt

* Warn when skipping an interaction for the first time

* add specific logger.debug message
2016-12-19 12:45:40 -08:00
Peter Eckersley 186a8c888f Path surgery makes sense for hooks that may be called from cron 2016-12-17 15:02:13 -08:00
Peter Eckersley 64daefea6b util.exe_exists and hooks._which were almost identical; merge them 2016-12-17 15:02:10 -08:00
Erica PortnoyandGitHub 81fd0cd32c Implement delete command (#3913)
* organize cert_manager.py

* add delete files to cert manager and storage

* add tests

* add to main and cli

* Clean up all related files we can find, even if some are missing.

* error messages, debug logs, and remove RenewerConfiguration

* add logs for failure to remove

* remove renewer_config_file
2016-12-15 20:23:02 -08:00
Erica PortnoyandPeter Eckersley 16361bfd06 test using os.path.sep not hardcoded / (#3920) 2016-12-15 19:41:42 -08:00
Peter Eckersley 99482e8047 Document subtle new semantics 2016-12-15 17:41:34 -08:00
Peter Eckersley de77dd74ad Unbreak repeated insertion logic 2016-12-15 17:31:32 -08:00
Peter Eckersley 33de782fba Make post hooks run in deterministic order 2016-12-15 17:28:16 -08:00
Peter Eckersley 0c2dc60484 Integration tests for hooks 2016-12-15 17:28:16 -08:00
Peter Eckersley 6f9abde894 Support intricate combinations of pre-hooks in different lineages 2016-12-15 17:28:16 -08:00
Peter Eckersley 0bea6c7350 Log when we run renew hooks (why weren't we doing this already?) 2016-12-15 17:28:16 -08:00
Peter Eckersley 876a760a91 Begin implementing pre / post-hook preservation 2016-12-15 17:28:16 -08:00
Erica PortnoyandBrad Warren 27525fb205 Use relative paths for livedir symlinks (#3914)
* Use relative paths for livedir symlinks

* switch directory back for the rest of the tests
2016-12-15 11:00:07 -08:00
Peter EckersleyandGitHub 107851ee9b Document defaults (#3863)
* Begin fixing incorrect defaults

* Fix more defaults

* Make more defaults correct

* Update cli-help.txt

(To show what this PR does)

* Lint

* Extend argparse rather than vendoring it

* lint

* Move sample User Agent generation into the same module as UA generation

* Revert cli-help.txt to previous release version

* Slightly more consistent linebreaks
2016-12-13 17:32:46 -08:00
Peter EckersleyandGitHub 0464ba2c4b Implement our fancy new --help output (#3883)
* Start reorganising -h output

* Fix the --debug flag

  - Currently exceptions are often caught and burried in log files, even
    if this flag is provided!

* Explain the insanity

* Parallalelise nosetests from tox (#3836)

* Parallalelise nosetests from tox

* Parallelise even more things, break even more things

* Now unbreak all the tests that aren't ready for ||ism

* Try to pass tests!

 - Remove non-working hack in reporter_test
 - also be selective about ||ism in the cover environment

* Try again

* certbot-apache tests also work, given enough time

* Nginx may need more time in Travis's cloud

* Unbreak reporter_test under ||ism

* More timeout

* Working again?

* This goes way faster

* Another big win

* Split a couple more large test suites

* A last improvement

* More ||ism!

* ||ise lint too

* Allow nosetests to figure out how many cores to use

* simplify merge

* Mark the new CLI tests as ||izable

* Simplify reporter_test changes

* Rationalise ||ism flags

* Re-up coverage

* Clean up reporter tests

* Stop modifying testdata during tests

* remove unused os

* Improve the "certbot certificates" output (#3846)

* Begin making "certbot certificates" future safe

* Handle the case where a renewal conf file has no "server" entry

* Improvements, tweaks

* Capitalise on things

* Print the command summary for -h and -h all, but not otherwise

Also, update nginx not installed CLI hint

* Add a "certificates" help section

* Clean up usage string construction

* Greatly improve "certbot -h TOPIC"

  - subcommands now get their own usage headings if they want them
  - added "certbot -h commands"

* A few more cli formatting tests

* Auto-populate the verb subgroups from the docs

* Show the new help output

* Lint, tweak

* More lint, and cleanup

* Infinite lint

* Add rename to command summary; sort "-h commands" output

* Use fancy string formatting

* More space

* Implement --help manage

Also, implement a general mechanism for documenting subcommands within
topics

* Remove one comma

* Only create weird parser structures if -h is provided :)

* Update sample cli out

* Lint

* Revert cli-help.txt to previous release version

* Grammar & style
2016-12-13 14:19:47 -08:00
FrankandPeter Eckersley e6f24db624 Sort the names by domain (then subdomain) before showing them (#3892)
* Sort the names by domain (then subdomain) before showing them

* Sort the names in display + tests
2016-12-11 02:18:32 -08:00
Joona HoikkalaandPeter Eckersley e9f040e209 Make default renewal file permissions more strict (#3891) 2016-12-10 11:19:20 -08:00
Peter EckersleyandBrad Warren 22e0f5779a Fix --debug (#3877)
* Fix the --debug flag

  - Currently exceptions are often caught and burried in log files, even
    if this flag is provided!

* Explain the insanity

* Make things slightly nicer
2016-12-09 14:56:14 -08:00
Erica PortnoyandPeter Eckersley 4a4977a54d Make renew command respect the --cert-name flag (#3880)
* Renew command respects --cert-name flag

* Error out early if requested cert doesn't exist
2016-12-08 18:27:23 -08:00
Erica PortnoyandGitHub 0a7ca2f32e Implement the --cert-name flag to select a lineage by its name, and the rename verb. (#3785)
* Rename and simplify main functions

* pass certname to auth method

* find cert by certname flag

* Implement --cert-name command

* don't ask to confirm new cert when we have domains and no existing certs with the lineage name

* Refactor and add --new-cert-name flag

* add interactivity to rename verb

* allow noninteractive and more descriptive function names
2016-12-08 11:53:30 -08:00
Peter EckersleyandErica Portnoy cc86ff2a21 Improve the "certbot certificates" output (#3846)
* Begin making "certbot certificates" future safe

* Handle the case where a renewal conf file has no "server" entry
2016-12-07 16:02:13 -08:00
Thomas Mayer 823cba55e3 Avoid eval() (#3844) 2016-12-07 23:02:42 +01:00
Peter EckersleyandGitHub 59c602d9ca Parallalelise nosetests from tox (#3836)
* Parallalelise nosetests from tox

* Parallelise even more things, break even more things

* Now unbreak all the tests that aren't ready for ||ism

* Try to pass tests!

 - Remove non-working hack in reporter_test
 - also be selective about ||ism in the cover environment

* Try again

* certbot-apache tests also work, given enough time

* Nginx may need more time in Travis's cloud

* Unbreak reporter_test under ||ism

* More timeout

* Working again?

* This goes way faster

* Another big win

* Split a couple more large test suites

* A last improvement

* More ||ism!

* ||ise lint too

* Allow nosetests to figure out how many cores to use

* simplify merge

* Mark the new CLI tests as ||izable

* Simplify reporter_test changes

* Rationalise ||ism flags

* Re-up coverage

* Clean up reporter tests

* Stop modifying testdata during tests

* remove unused os
2016-12-06 20:39:16 -08:00
Erica PortnoyandPeter Eckersley f0a7bb0e33 Mark Nginx vhosts as ssl when any vhost is on ssl at that address (#3856)
* Move parse_server to be a method of NginxParser

* add super equal method to more correctly check addr equality in nginx should we support ipv6 in nginx in the future

* add addr:normalized_tuple method

* mark addresses listening sslishly due to another server block listening sslishly on that address

* test turning on ssl globally

* add docstring

* lint and remove extra file
2016-12-05 19:17:04 -08:00
Blake GriffithandErica Portnoy 65d9e997e5 Refactor cli_test.py and main_test.py (#3828)
* Begin breaking out cli_test.py

* simplify main

* refactor porse tests

* move determine account tests to main_test.py

* move duplicate cert test to main_test.py

* move cli stuff out of the way

* add test_renewal.py

* move error test into error_handler_test.py

* move test_read_file

* move test_no_gui out of MainTest

* move test_install_abspath to parsetest

* Move main tests into main_test.py

* move cli tests back into cli_test.py

* clean up cli_test.py

* move punycode test to util_test.py

* Fix NameError from missing plugins_disco

* Fix linting errors

* test_renewal.py -> renewal_test.py

* rm not_cli_test.py

* Move main._handle_exception test to main_test.py

* Move renewal import in renewal_test.py

from @ohemorange comments

* certbot.tests.test_util -> certbot.tests.util

* Fix issues from rebasing.

* Fix testing issue with option_was_set

* fix linting issue
2016-12-05 15:22:14 -08:00
Thomas Mayer 7767f62a2e Remove recently added test (#3844) 2016-12-03 07:22:55 +01:00
Thomas Mayer 0e237e1c0b Preserve --must-staple in configuration for renewal (#3844) 2016-12-03 06:59:32 +01:00
Brad WarrenandPeter Eckersley da3332ccfa Security enhancement cleanup (#3837)
* Stop passing around config and refactor tests

* Refactor and warn during enhance_config

* Use mock.ANY to make new Pythons happy

* Remove verbose enhance_config from test names

* Fix spacing in warning
2016-12-02 16:03:55 -08:00
Mario VillaplanaandBrad Warren ec0cd4d538 Warn early if a selected enhancement is unsupported by the current plugin (#3688)
Certbot currently silently allows a user to specify enhancements that are
unsupported by the chosen plugin. This adds an early warning message
indicating when a selected enhancement isn't supported by a plugin.
2016-11-30 10:50:16 -08:00
Craig SmithandPeter Eckersley 83966cdfcf Fixed output (#3637). (#3809) 2016-11-29 16:53:06 -08:00
Craig SmithandPeter Eckersley df5f08843f Output success message for revoke command (#3823)
* Output status for `revoke` operation. Fixes #2819.

    - Added method to `certbot.display.ops` to output confirmation of `revoke`.

    - Wrapped call to `acme.client.Client.revoke` in a try to statement to
      handle possible error.

    - Added test for `main.revoke`.

* Added test for failure of certificate revocation.

Moved creation of mocks into RevokeTest setup function.

Stopped mocks in RevokeTest teardown function.

* Fixed lint errors.

* Do not call `unittest.TestCase.assertRaises` as a context manager (to work with py26).

* Fixed spelling error in successful revocation notification.

Added test for the notification.
2016-11-29 15:30:37 -08:00
Brad WarrenandPeter Eckersley e5f4d0cb5c Fix reinstall message (#3784)
* Changed informational messages because of confusing message on reinstallation.

Certbot prompts the user when it detects that an appropriately fresh certificate
is already available:

        You have an existing certificate that contains exactly the same domains you requested and isn't close to expiry.
        (ref: <path>)

        What would you like to do?
        -------------------------------------------------------------------------------
        1: Attempt to reinstall this existing certificate
        2: Renew & replace the cert (limit ~5 per 7 days)
        -------------------------------------------------------------------------------
        Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1

On selecting '1' (reinstall), the resulting message is:

        -------------------------------------------------------------------------------
        Your existing certificate has been successfully reinstalled, and the new
        certificate has been installed.

        The new certificate covers the following domains: https://<whatever>

        You should test your configuration at:
        https://www.ssllabs.com/ssltest/analyze.html?d=<whatever>
        -------------------------------------------------------------------------------

"Your existing certificate has been successfully reinstalled" <-- Okay

"and the new certificate has been installed." <-- Wait, what?

The issue appears to come from assumptions in certbot/certbot/main.py

It uses `len(lineage.available_versions("cert"))` to determine if this was a
fresh install or renewal, and then calls either `display_ops.success_renewal()`
(which produces the "existing certificate ... and the new certificate" language)
or `display_ops.success_installation()` (which has no messaging about existing
vs. new certificates).

The len(lineage) test isn't the right way to make this choice. The certificate's
lineage length doesn't imply anything about whether we've just obtained a new
certificate, because there is no new certificate in the case of a "reinstall"
action.

The new logic calls `display_ops.success_installation()` on all "reinstall"
actions, and otherwise employs the existing `len(lineage)` test.

Additionally the `display_ops.success_installation()` has been enhanced to
accept an action parameter, and has the message reworded slightly to make
sense regardless of the action passed. The messaging is mostly unchanged if it's
called without the action parameter:

Original message:
        -------------------------------------------------------------------------------
        Congratulations! You have successfully enabled https://<whatever>

        You should test your configuration at:
        https://www.ssllabs.com/ssltest/analyze.html?d=<whatever>
        -------------------------------------------------------------------------------

New message on initial install:
        -------------------------------------------------------------------------------
        Congratulations! You have successfully installed a certificate for
        https://<whatever>

        You should test your configuration at:
        https://www.ssllabs.com/ssltest/analyze.html?d=<whatever>
        -------------------------------------------------------------------------------

New message on re-install:
        -------------------------------------------------------------------------------
        Congratulations! You have successfully reinstalled a certificate for
        https://<whatever>

        You should test your configuration at:
        https://www.ssllabs.com/ssltest/analyze.html?d=<whatever>
        -------------------------------------------------------------------------------

* Typo in display message.

* Typo, characters transposed.

* undo changes to certbot/display/ops.py

* remove invalid todos

* Test success_installation() called for reinstall

* Simplify display_ops.success* functions

* refactor and expand run() tests
2016-11-15 11:56:05 -08:00
Brad WarrenandPeter Eckersley 3dbeef8ee7 fix --http-01-port typo at source (#3794) 2016-11-15 11:45:07 -08:00
Erica Portnoyandschoen 04bec308fb Add README file to each live directory explaining its contents. (#3696)
* Add README file to each live directory explaining its contents.

* add tests

* Update README copy

* add fragment

* update copy

* lint errors
2016-11-09 12:55:18 -08:00
Erica PortnoyandBrad Warren af46f644a7 Add list-certs command (#3669)
* Switch to using absolute path in symlink

* save archive_dir to config and read it back

* cli_config.archive_dir --> cli_config.default_archive_dir

* Use archive_dir specified in renewal config file

* add helpful broken symlink info

* add docstring to method

* Add tests

* remove extraneous test imports

* fix tests

* py2.6 syntax fix

* git problems

* Add list-certs command

* no dict comprehension in python2.6

* add test coverage

* More py26 wrangling

* update tests for py3 and lint

* remove extra dep from test

* test coverage

* test shouldn't be based on dict representation order

* Redo report UX and add tests to cover

* remove storage str test

* lint and use mock properly

* mock properly

* address code review comments

* lineage --> certificate name and print fullchain and privkey paths

* make py26 happy

* actually make py26 happy

* don't wrap text
2016-11-08 15:21:42 -08:00
Erica Portnoyandschoen 2b229d4b9d Allow notification interface to not wrap text (#3728) 2016-11-07 16:14:09 -08:00
Gilles PietriandPeter Eckersley 0bc3e1860b Add renew_hook to options stored in the renewal config, partially tackles #3394 (#3724) 2016-11-07 15:31:50 -08:00
Joona HoikkalaandPeter Eckersley d741e684d0 Script plugin (#3521)
* Script plugin initial commit

* Fix auth script path

* Return correct responses

* Added DNS-01 support

* Report the challenge pref correctly

* Use config root from certbot constants rather than hardcoded

* Remove prehook and rename posthook to cleanup for clarity

* Refactoring

* Docs

* Refactoring

* Refactoring continued, working now

* Use global preferred-challenges argument in favor of local

* Added http-01 as fallback challenge if not defined

* Do not continue if auth script not defined

* Skip unnecessary steps when running

* Read config values from correct places

* Tests and minor fixes

* Make Python 2.6 happy again

* Added CERTBOT_AUTH_OUTPUT and better tests

* Lint & Py3 fixes

* Make Python 2.6 happy again

* Doc changes

* Refactor hook execute and reuse in script plugin

* Refactored hook validation

* Added long_description for plugin help text

* Refactored env var writing
2016-11-07 15:22:48 -08:00
kaiyouandPeter Eckersley 82c69815d1 Fix writing pem files with Python3 (#3757)
* Standardize arguments name for mode and chmod in the util API

* Handle OpenSSL pem as bytes objects only for Python3 compatibility

* Handle OpenSSL pem as bytes objects only (remaining bits)

* Manipulate bytes objects only when testing PEM-related functions

* Fix argument order when calling util.unique_file
2016-11-07 14:22:20 -08:00
Nick FongandBrad Warren 549f0eccf9 Remove get_all_certs_keys() from interfaces.py (#3753)
- Remove method 'get_all_certs_keys()' from interfaces.py
- Also remove 'get_all_certs_keys()' from plugins/null.py and
  corresponding unit test
2016-11-07 11:36:58 -08:00
Brad WarrenandPeter Eckersley fd95a55054 use terminate not kill (#3750) 2016-11-04 18:39:58 -07:00
Jacob Hoffman-AndrewsandBrad Warren db4c88856a Fix non-ASCII domain check. (#3727)
* Fix non-ASCII domain check.

Previously, the code would convert to utf-8, check for non-ASCII, and then try
to use .format() to interpolate the result into an error message. This would
generate a second error that would cause the whole message to get dropped, and
the program to silently exit. The problem can be succinctly observed like so:

$ python
>>> "{0}".format("ウェブ.crud.net")
'\xe3\x82\xa6\xe3\x82\xa7\xe3\x83\x96.crud.net'
>>> "{0}".format(u"ウェブ.crud.net")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)

Note for the curious: This problem only seems to happen with .format():

>>> "%s" % ("ウェブ.crud.net")
'\xe3\x82\xa6\xe3\x82\xa7\xe3\x83\x96.crud.net'
>>> "%s" % (u"ウェブ.crud.net")
u'\u30a6\u30a7\u30d6.crud.net'
2016-11-02 16:14:14 -07:00
Erica PortnoyandPeter Eckersley 981d59fb45 Specify archive directory in renewal configuration file (#3661)
* Switch to using absolute path in symlink

* save archive_dir to config and read it back

* cli_config.archive_dir --> cli_config.default_archive_dir

* Use archive_dir specified in renewal config file

* add helpful broken symlink info

* add docstring to method

* Add tests

* remove extraneous test imports

* fix tests

* py2.6 syntax fix

* git problems

* no dict comprehension in python2.6

* add test coverage

* More py26 wrangling
2016-10-27 17:23:21 -07:00
Erica PortnoyandGitHub 4b5db7aec4 Allow user to select all domains by typing empty string at checklist (#3693)
* Allow user to select all domains by typing empty string at checklist
2016-10-26 15:43:40 -07:00
Patrick FigelandBrad Warren 1dafaec5a9 Update CLI usage docs for --csr (#3677)
With #2403 and #3046, certbot gained the ability to parse CSRs
encoded as PEM and without a SAN extension. Update the CLI usage
docs to reflect this change.
2016-10-25 13:56:38 -07:00
Jay FaulknerandBrad Warren 98911d0c3c Fix issue with suggest_unsafe undeclared (#3685)
Added missing declaration of support_unsafe and unit test to prevent
regression.

Issue #3672
2016-10-24 14:51:50 -07:00
Erica PortnoyandBrad Warren d54cb76432 Remove the curses dialog, thereby deprecating the --help and --dialog command line options (#3665)
* Remove the curses dialog, thereby deprecating the --help and --dialog command line options

* Deprecate --dialog and suppress --text
2016-10-21 15:45:57 -07:00
schoenandBrad Warren 605a3cc931 Stop rejecting punycode domain names (#3626)
* Punycode is about to be permitted; stop rejecting it

* Remove spurious bracket

* More brackets rather than fewer!

* Change ops_test's notion of valid domains

* Remove spurious "certonly" from new test

* Make test more localized

* Remove commented-out punycode prohibition
2016-10-17 19:48:48 -07:00