1
0
mirror of https://github.com/certbot/certbot.git synced 2025-09-10 22:11:53 +03:00

328 Commits

Author SHA1 Message Date
Erica Portnoy
54b4758c27 Merge branch 'master' into warnings-are-errors 2018-10-30 17:18:00 -07:00
ohemorange
36ebce4a5f Fix ranking of vhosts in Nginx so that all port-matching vhosts come first (#6412)
To more closely match how Nginx ranks things.
2018-10-19 19:16:54 -07:00
sydneyli
8dd68a6551 Add and test new nginx parsing abstractions (#6383)
* feat(nginx): add and test new parsing abstractions

* chore(nginx parser): fix mypy and address small comments

* chore(nginx parser): clean up by removing context object

* fix integration test and lint
2018-10-19 12:30:32 -07:00
ohemorange
22da2447d5 Stop caching the results of ipv6_info in http01.py (#6411)
Stop caching the results of ipv6_info in http01.py. A call to choose_vhosts might change the ipv6 results of later calls. Add tests for this and default_listen_addresses more broadly.
2018-10-17 10:54:43 -07:00
ohemorange
139ef20650 Add debugging info for Nginx tls-sni and http integration tests purposes (#6414) 2018-10-15 10:41:04 -07:00
ohemorange
3ef43e4d88 Update parser to match new Nginx functionality (#6381)
Previously, Nginx did not allow `${` to start a variable name. Now it's allowed to. This means we'll be more permissible than Nginx when people are on older versions of Nginx, but it's unlikely anyone was relying on this to fail in the first place, so that's probably ok.
2018-09-18 12:52:11 -07:00
David Beitey
38b1d9d6ba More detailed error logging for nginx plugin (#6175)
This makes errors more useful when Nginx can't be found or when Nginx's
configuration can't be found.  Previously, a generic
`NoInstallationError` isn't descriptive enough to explain _what_ wasn't
installed or what failed without going digging into the source code.
2018-09-12 16:48:50 -07:00
Sam Bull
a3b858db34 Exclude one-time use parameters. Fixes #6118 (#6223)
* Exclude one-time use parameters. Fixes #6118

* Fix error.

* Delete items inplace, rather than creating new list.

* Fix stupid mistake.

* Use .index() for stability.

* Try previous idea while resetting the index.

* Shorter comment for pylint.

* More readable approach

* Fix whitespace
2018-09-12 16:38:37 -07:00
Brad Warren
fdb3c8df4b s/assertEquals/assertEqual 2018-07-11 17:33:04 -07:00
Jacob Hoffman-Andrews
0672e63176 Remove main components from Alpha. (#6187)
acme, certbot, and the Nginx and Apache plugins should no longer be considered alpha-quality.
2018-07-10 13:52:58 -07:00
Brad Warren
742a57722b fix server_root default tests on macOS (#6149) 2018-06-27 17:35:43 -07:00
ohemorange
87e1912bf9 Show both possible Nginx default server root values in docs (#6137)
See https://github.com/certbot/website/pull/348#issuecomment-399257703.

```
$ certbot --help all | grep -C 3  nginx-server-root
nginx:
  Nginx Web Server plugin - Alpha

  --nginx-server-root NGINX_SERVER_ROOT
                        Nginx server root directory. (default: /etc/nginx)
  --nginx-ctl NGINX_CTL
                        Path to the 'nginx' binary, used for 'configtest' and
 ```

```
$ CERTBOT_DOCS=1 certbot --help all | grep -C 3  nginx-server-root
nginx:
  Nginx Web Server plugin - Alpha

  --nginx-server-root NGINX_SERVER_ROOT
                        Nginx server root directory. (default: /etc/nginx or
                        /usr/local/etc/nginx)
  --nginx-ctl NGINX_CTL
```

* Show both possible Nginx default server root values in docs

* add test

* check that exactly one server root is in the default

* use default magic
2018-06-25 18:09:30 -07:00
ohemorange
d905886f4c Automatically select among default vhosts if we have a port preference in nginx (#5944)
* automatically select among default vhosts if we have a port preference

* ports should be strings in the nginx plugin

* clarify port vs preferred_port behavior by adding allow_port_mismatch flag

* update all instances of default_vhosts to all_default_vhosts

* require port

* port should never be None in _get_default_vhost
2018-06-05 13:40:48 -07:00
sydneyli
09a28c7a27 Allow multiple add_headers directives (#6068)
* fix(nginx-hsts): allow multiple add_headers

* test(nginx): fix nginx tests
2018-06-04 17:44:51 -07:00
ohemorange
a1f5dc27f2 Add domain to error message when no matching server block found (#6034) 2018-05-23 14:03:30 -07:00
ohemorange
0d3a157525 Merge pull request #6020 from certbot/mabayhan-patch
Set correct Nginx server root on FreeBSD and Darwin
2018-05-21 16:53:11 -07:00
Erica Portnoy
1239d7a881 check platform with correct python 2018-05-17 20:02:27 -07:00
James Payne
5300d7d71f Fix Pylint upgrade issues
* Remove unsupported pylint disable options
    * star-args removed in Pylint 1.4.3
    * abstract-class-little-used removed in Pylint 1.4.3

* Fixes new lint errors

* Copy dummy-variable-rgx expression to new ignored-argument-names expression to ignore unused funtion arguments

* Notable changes
    * Refactor to satisfy Pylint no-else-return warning
    * Fix Pylint inconsistent-return-statements warning
    * Refactor to satisfy consider-iterating-dictionary
    * Remove methods with only super call to satisfy useless-super-delegation
    * Refactor too-many-nested-statements where possible
    * Suppress type checked errors where member is dynamically added (notably derived from josepy.JSONObjectWithFields)
    * Remove None default of func parameter for ExitHandler and ErrorHandler

Resolves #5973
2018-05-16 20:37:39 +00:00
James Hiebert
307f45f88f Enable checking of type annotation in Nginx plugin (#5997)
* Adds type checking for certbot-nginx

* First pass at type annotation in certbot-nginx

* Ensure linting is disabled for timing imports

* Makes container types specific per PR comments

* Removes unnecessary lint option
2018-05-15 09:36:47 -07:00
ohemorange
832941279b Specify that every domain name needs to be under a server_name directive (#5949) 2018-05-10 16:46:57 -07:00
mabayhan
b39507c5af Update constants.py
Fixed comma.
2018-04-17 09:09:27 -07:00
mabayhan
c443db0618 Update constants.py
On FreeBSD or MacOS, "certbot --nginx" fails. The reason is, at these op. systems, nginx directory is different than linux.
2018-04-12 16:33:10 -07:00
ohemorange
bdaccb645b Support quoted server names in Nginx (#5811)
* Support quoted server names in Nginx

* add unit test to check that we strip quotes

* update configurator test
2018-04-03 12:14:23 -07:00
Joona Hoikkala
f5ad08047b Fix comparison to check values (#5815) 2018-04-03 12:04:57 -07:00
ohemorange
669312d248 We don't try to add location blocks through a mechanism that checks REPEATABLE_DIRECTIVES, and it wouldn't work as an accurate check even if we did, so just remove it (#5787) 2018-03-27 15:25:34 -07:00
ohemorange
4d082e22e6 Remove ipv6only=on from duplicated vhosts (#5793)
* rename delete_default to remove_singleton_listen_params

* update docstring

* add documentation to obj.py

* add test for remove duplicate ipv6only

* Remove ipv6only=on from duplicated vhosts

* add test to make sure ipv6only=on is not erroneously removed
2018-03-27 15:11:39 -07:00
ohemorange
804fd4b78a factor out location_directive_for_achall (#5794) 2018-03-26 16:28:30 -07:00
ohemorange
e9707ebc26 Allow 'default' along with 'default_server' in Nginx (#5788)
* test default detection

* Allow 'default' along with 'default_server' in Nginx

* Test that default gets written out as default_server in canonical string

* remove superfulous parens
2018-03-26 14:56:31 -07:00
ohemorange
8d0d42a739 Refactor _add_directive into separate functions (#5786)
* Refactor _add_directive to separate functions

* UnspacedList isn't idempotent

* refactor parser in add_server_directives and update_or_add_server_directives

* update parser tests

* remove replace=False and add to update_or_add for replace=True in configurator

* remove replace=False and add to update_or_add for replace=True in http01

* update documentation
2018-03-23 16:30:13 -07:00
Alokin Software Pvt Ltd
693cb1d162 Support Openresty in the NGINX plugin (#5467)
* fixes #4919 openresty_support

* making the regex more general

* reformatting warning to pass lint

* Fix string formatting in logging function

* Fix LE_AUTO_VERSION
2018-03-22 17:50:05 -07:00
sydneyli
79d90d6745 feat(nginx plugin): add HSTS enhancement (#5463)
* feat(nginx plugin): add HSTS enhancement

* chore(nginx): factor out block-splitting code from redirect & hsts enhancements!

* chore(nginx): merge fixes

* address comments

* fix linter: remove a space

* fix(config): remove SSL directives in HTTP block after block split, and remove_directive removes 'Managed by certbot' comment

* chore(nginx-hsts): Move added SSL directives to a constant on Configurator class

* fix(nginx-hsts): rebase on wildcard cert changes
2018-03-16 15:27:39 -07:00
ohemorange
8bc9cd67f0 Fix ipv6only detection (#5648)
* Fix ipv6only detection

* move str() to inside ipv6_info

* add regression test

* Update to choose_vhosts
2018-03-01 15:08:53 -08:00
ohemorange
f0b337532c Nginx plugin wildcard support for ACMEv2 (#5619)
* support wildcards for deploy_cert

* support wildcards for enhance

* redirect enhance and some tests

* update tests

* add display_ops and display_repr

* update display_ops_test and errors found

* say server block

* match redirects properly

* functional code

* start adding tests and lint errors

* add configurator tests

* lint

* change message to be generic to installation and enhancement

* remove _wildcard_domain

* take selecting vhosts out of loop

* remove extra newline

* filter wildcard vhosts by port

* lint

* don't filter by domain

* [^.]+

* lint

* make vhost hashable

* one more tuple
2018-03-01 14:05:49 -08:00
ohemorange
8a9f21cdd3 Fix Nginx redirect issue (#5479)
* wrap redirect in if host matches

* return 404 if we've created a new block

* change domain matching to exact match

* insert new redirect directive at the top

* add a redirect block to the top if it doesn't already exist, even if there's an existing redirect

* fix obj tests

* remove active parameter

* update tests

* add back spaces

* move imports

* remove unused code
2018-01-24 22:19:32 -08:00
ohemorange
e9b57e1783 Add (nonexistent) document root so we don't use the default value (#5437) 2018-01-17 08:02:10 -08:00
ohemorange
2c379cd363 Add a rewrite directive for the .well-known location so we don't hit existing rewrites (#5436) 2018-01-17 08:01:44 -08:00
ohemorange
7e463bccad Handle more edge cases for HTTP-01 support in Nginx (#5421)
* only when using http01, only match default_server by port

* import errors

* put back in the code that creates a dummy block, but only when we can't find anything else
2018-01-16 14:58:45 -08:00
ohemorange
2cb9d9e2aa Implement HTTP-01 challenge for Nginx (#5414)
* get http01 challenge working

* support multiple challenge types in configurator.py

* update existing nginx tests

* lint

* refactor NginxHttp01 and NginxTlsSni01 to both now  inherit from NginxChallengePerformer

* remove TODO

* challenges_test tests with both tlssni01 and http01

* Make challenges.py more abstract to make lint happier

* add pylint disables to the tests to make pylint happier about the inheritance and abstraction situation

* no need to cover raise NotImplementedError() lines

* python3 compatibility

* test that http01 perform is called

* only remove ssl from addresses during http01

* Initialize addrs_to_add

* Change Nginx http01 to modify server block so the site doesn't stop serving while getting a cert

* pass existing unit tests

* rename sni --> http01 in unit tests

* lint

* fix configurator test

* select an http block instead of https

* properly test for port number

* use domains that have matching addresses

* remove debugger

* remove access_log and error_log cruft that wasn't being executed

* continue to return None from choose_redirect_vhost when create_if_no_match is False

* add nginx integration test
2018-01-11 17:06:23 -08:00
Brad Warren
9e95208101 Factor out common challengeperformer logic (#5413) 2018-01-10 18:34:45 -08:00
Noah Swartz
a7d00ee21b print as a string (#5359) 2018-01-04 13:59:29 -08:00
Jannis Leidel
2abc94661a Use josepy instead of acme.jose. (#5203) 2017-12-11 11:25:09 -08:00
ohemorange
8b5d6879cc Create a new server block when making server block ssl (#5220)
* create_new_vhost_from_default --> duplicate_vhost

* add source_path property

* set source path for duplicated vhost

* change around logic of where making ssl happens

* don't add listen 80 to newly created ssl block

* cache vhosts list

* remove source path

* add redirect block if we created a new server block

* Remove listen directives when making server block ssl

* Reset vhost cache on parser load

* flip connected pointer direction for finding newly made server block to match previous redirect search constraints

* also test for new redirect block styles

* fix contains_list and test redirect blocks

* update lint, parser, and obj tests

* reset new vhost (fixing previous bug) and move removing default from addrs under if statement

* reuse and update newly created ssl server block when appropriate, and update unit tests

* append newly created server blocks to file instead of inserting directly after, so we don't have to update other vhosts' paths

* add coverage for NO_IF_REDIRECT_COMMENT_BLOCK

* add coverage for parser load calls

* replace some double quotes with single quotes

* replace backslash continuations with parentheses

* update docstrings

* switch to only creating a new block on redirect enhancement, including removing the get_vhosts cache

* update configurator tests

* update obj test

* switch delete_default default for duplicate_vhost
2017-12-07 09:48:54 -08:00
Brad Warren
abed73a8e4 Revert "Nginx reversion (#5299)" (#5305)
This reverts commit c9949411cd.
2017-12-06 17:45:20 -08:00
Brad Warren
c9949411cd Nginx reversion (#5299)
The reason for this PR is many bug fixes in the nginx plugin for changes we haven't released yet are included in #5220 which may not make our next release. If it doesn't, we will (mostly) revert the nginx plugin back to its previous state to avoid releasing these bugs and will revert this PR after the release.

* Revert "Nginx IPv6 support (#5178)"

This reverts commit 68e37b03c8.

* Revert "Fix bug that stopped nginx from finding new server block for redirect (#5198)"

This reverts commit e2ab940ac0.

* Revert "Nginx creates a vhost block if no matching block is found (#5153)"

This reverts commit 95a7d45856.
2017-12-05 20:04:08 -08:00
Brad Warren
48173ed1cb Switch from nose to pytest (#5282)
* Use pipstrap to install a good version of pip

* Use pytest in cb-auto tests

* Remove nose usage in auto_test.py

* remove nose dev dep

* use pytest in test_tests

* Use pytest in tox

* Update dev dependency pinnings

* remove nose multiprocess lines

* Use pytest for coverage

* Use older py and pytest for old python versions

* Add test for Error.__str__

* pin pytest in oldest test

* Fix tests for DNS-DO plugin on py26

* Work around bug for Python 3.3

* Clarify dockerfile comments
2017-12-01 10:59:55 -08:00
Joona Hoikkala
68e37b03c8 Nginx IPv6 support (#5178)
* Nginx IPv6 support

* Test and lint fixes

* IPv6 tests to Nginx plugin

* Make ipv6_info() port aware

* Named tuple values for readability

* Lint fix

* Requested changes
2017-10-31 19:41:32 -05:00
ohemorange
e2ab940ac0 Fix bug that stopped nginx from finding new server block for redirect (#5198)
* fix bug that stopped nginx from finding new server block for redirect

* add regression test
2017-10-20 16:46:36 -07:00
ohemorange
3c1dafa9e9 Correctly test for existing Certbot redirect when adding an Nginx redirect block (#5192)
* add test that should fail on completion of this PR

* fix double redirect problem

* update existing test to match new whitespace
2017-10-19 14:56:53 -07:00
ohemorange
95a7d45856 Nginx creates a vhost block if no matching block is found (#5153)
* Allow authentication if there's no appropriate vhost

* Update test

* add flag to suppress raising error if no match is found

* Allow installation if there's no appropriate vhost

* remove traceback

* make new vhost ssl

* Fix existing bugs in nginxparser.py and obj.py

* Switch isinstance(x, str) to isinstance(x, six.string_types) in the Nginx plugin

* remove unused import

* remove unneeded custom copy from Addr

* Add docstring for create_new_vhost_from_default

* add test for create_new_vhost_from_default

* add configurator tests and leave finding the first server block for another PR

* don't assume order from a set

* address multiple default_server problem

* don't add vhosts twice

* update unit tests

* update docstring

* Add logger.info message for using default address in tlssni01 auth
2017-10-13 12:29:02 -07:00
Joona Hoikkala
232f5a92d1 Fix naming in error message (#5181) 2017-10-11 08:18:41 -07:00