Commit graph

58 commits

Author SHA1 Message Date
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
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
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
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
ohemorange
0321c0cb4c Change add_server_directives replace=True behavior to attempt to replace, but append on failure to find. (#4956)
* Change add_server_directives replace=True behavior to attempt to replace, but append on failure to find.

* Remove try/except around add_server_directives
2017-07-26 13:57:25 -07:00
ohemorange
23e6c28d80 Allow Nginx to insert include files with comments inside (#4666)
* add failing test case

* allow include files to insert comments

* lint
2017-05-15 15:30:50 -07:00
ohemorange
7016874243 Switch to using include directive for Nginx constants (#4557)
* Switch to using include directive for Nginx constants

* remove deprecated comment

* give better error message when attempting to insert an existing directive

* make code more readable

* add docstrings

* allow a duplicated directive if it's identical

* comment out precisely repeated directives

* add comments
2017-05-02 17:56:56 -07:00
ohemorange
1611df4120 Allow empty nginx blocks (#4555)
* modify test config file to allow valid config that fails to parse in parser.py

* make failing tests pass by fixing the problem
2017-04-26 18:44:06 -07:00
Erica Portnoy
7be2e79025 Fix nginx parser (#4296)
* rewrite nginx parser to allow everything that nginx does

* also make changes in tls_sni_01.py

* add test case with

* allow embedded variables

* allow empty ${} variable

* fix quotes

* un-special case if

* update all tests to reflect current parsing

* escape in QuotedString after merge

* add test cases for variable weirdness that are almost certainly nginx bugs

* update regex for correct variable rules

* close paren doesn't invoke last_space

* Make test file valid Nginx syntax
2017-03-24 19:45:53 -07:00
Yen Chi Hsuan
4cad594b4b Python 3 compatibility for all tests (#4358) 2017-03-17 13:10:02 -07:00
Erica Portnoy
e5909d379c Don't crash on listen unix: (#4259)
Fixes #4225.

* don't crash on listen unix:

* correctly merge #4221
2017-02-27 13:35:29 -08:00
silverwind
b1a4280519 Show error details for the nginx config parser (#4221)
Nginx parser errors now include helpful details on where parsing has
actually failed.

Related: https://github.com/certbot/certbot/issues/3798
2017-02-22 18:50:56 -08:00
Erica Portnoy
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
Nick Fong
dd8772b608 Remove get_all_certs_keys() from Apache and Nginx (#3768)
- Remove get_all_certs_keys() implementation in
    - certbot-apache/certbot_apache/configurator.py
- Remove corresponding tests for get_all_certs_keys() in
    - certbot-apache/certbot_apache/tests/configurator_test.py
- Remove get_all_certs_keys() implementation in
    - certbot-nginx/certbot_nginx/configurator.py
    - certbot-nginx/certbot_nginx/parser.py
- Remove corresponding tests for get_all_certs_keys() in:
    - certbot-nginx/certbot_nginx/tests/configurator_test.py
    - certbot-nginx/certbot_nginx/tests/parser_test.py

Resolves #3762
2016-11-08 17:19:05 -08:00
Erica Portnoy
df10a6431b Don't re-add redirects if one exists (#3751)
* Don't re-add redirects if one exists

* coverage

* make coverage happy

* don't re-add comment, and clean code
2016-11-07 15:48:46 -08:00
Erica Portnoy
4bc3c747cb Mark parsed Nginx addresses as listening sslishly when an ssl on directive is included in the server block. (#3607) 2016-10-10 19:04:35 -07:00
Erica Portnoy
c9bc034512 Update Nginx redirect enhancement process to modify appropriate blocks (#3546)
* Cache the vhost we find during nginx deployment for OCSP enhancement.

* Refactor to pass domain into enhancement functions

* Add https redirect to most name-matching block listening non-sslishly.

* Redirect enhancement chooses the vhost most closely matching target_name that is listening to port 80 without using ssl.

* Add default listen 80 directive when it is implicitly defined
2016-09-29 16:16:07 -07:00
Erica Portnoy
9f2dfc15fe Restructure how Nginx parser re-finds vhosts, and disable creating new server blocks. (#3528)
* Restructure add_server_directives to take a vhost as argument. This is the first step towards fixing vhost selection in nginx.

* Save path to vhost in file while parsing in get_vhosts().

* Disable creating a new server block when no names match.

* Make parser select vhost based on information in the vhost it found previously, rather than searching again for a match.

* Make add_server_directives update the passed vhost

* Update boulder config to pass test

* Add testing code for the _do_for_subarray function

* documentation and formatting updates
2016-09-26 13:13:29 -07:00
Peter Eckersley
df61b0e349 Check for comments more accurately 2016-08-18 13:56:15 -07:00
Brad Warren
449487e8cb Catch all pyparsing exceptions 2016-08-16 19:34:16 -07:00
Brad Warren
465aa38143 Revert "Catch all pyparsing exceptions"
This reverts commit 7fb5cf1cf5.
2016-08-16 19:33:19 -07:00
Brad Warren
76c2fe579a Make _comment_directive more defensive 2016-08-16 18:30:45 -07:00
Brad Warren
671d7ee194 Fix up COMMENT constants 2016-08-16 17:45:43 -07:00
Brad Warren
3d4f822be0 Handle case where block is empty -- not sure if it ever happens, but let's not error out unnecessarily 2016-08-16 16:41:23 -07:00
Brad Warren
ae23800e53 Comment code that confused bmw 2016-08-16 16:37:40 -07:00
Brad Warren
7fb5cf1cf5 Catch all pyparsing exceptions 2016-08-16 15:46:31 -07:00
Peter Eckersley
b5fa0fbad7 This is reportedly the correct magic 2016-08-08 18:08:11 -07:00
Peter Eckersley
f0c2ed3059 Lint, improve coverage, rm unused code 2016-08-08 15:45:49 -07:00
Peter Eckersley
cdc894601c Tolerate our own added newlines 2016-08-05 15:36:40 -07:00
Peter Eckersley
3a2df72bce Add newlines to the ends of blocks more correctly 2016-08-05 15:36:24 -07:00
Peter Eckersley
61b81b877d Merge remote-tracking branch 'origin/master' into no-conflicting-declarations3 2016-07-29 17:28:29 -07:00
Peter Eckersley
e1f560dca3 Neaten 2016-07-26 17:23:24 -07:00
Ville Skyttä
c7b89c334b Use logger.warning instead of deprecated warn 2016-07-22 09:54:28 +03:00
Peter Eckersley
e5cb04ee7d A couple of fixes 2016-07-21 13:26:57 -07:00
Brad Warren
2ce5b195e5 check certbot 2016-07-18 18:23:54 -07:00
Brad Warren
ed4fc9d2f7 call _comment_directive 2016-07-18 18:20:21 -07:00
Brad Warren
5dd8f70e56 better newline logic 2016-07-18 18:19:14 -07:00
Brad Warren
bd21325fcd newline logic 2016-07-18 18:12:44 -07:00
Brad Warren
aa33c0fa83 does it work? 2016-07-18 15:33:28 -07:00
Brad Warren
5d7ef49fac _add_directive cleanup 2016-07-18 15:25:09 -07:00
Brad Warren
dbb2398270 Add _comment_spaced_block 2016-07-15 09:25:12 -07:00
Brad Warren
9c915b0ae4 Fix tests 2016-07-14 18:15:01 -07:00
Brad Warren
6b639679e8 Merge branch 'master' into no-conflicting-declarations 2016-07-14 17:26:39 -07:00
Peter Eckersley
6017a6cb6d Only write nginx config files if we've modified them 2016-06-27 12:44:36 -07:00
Peter Eckersley
db66050a7a Make atomicity comment more accurate 2016-06-23 11:41:31 -07:00
Peter Eckersley
098d23ac98 Comment a couple of things 2016-06-21 15:33:57 -07:00
Peter Eckersley
884b21ffbe fix docstring typo 2016-06-21 15:11:32 -07:00
Peter Eckersley
e4f88506cc Fix TLS_SNI & associated tests 2016-06-18 14:52:07 -07:00