Commit graph

11078 commits

Author SHA1 Message Date
ohemorange
f94c981dfd
[apache] Add type hints to apache obj and http_01 for mypy --strict (#10154)
```
$ mypy --strict certbot-apache/certbot_apache/_internal/http_01.py 
Success: no issues found in 1 source file
$ mypy --strict certbot-apache/certbot_apache/_internal/obj.py 
Success: no issues found in 1 source file
```

PEP 526 says to declare types of unpacked tuples beforehand:
https://peps.python.org/pep-0526/#global-and-local-variable-annotations.
Could have just declared it in apache, but improved the acme return type
while I was at it.

Once again, `typing.Pattern` is deprecated in favor of `re.Pattern` so
changing that while parametrizing the type
2025-01-28 16:33:12 -08:00
Brad Warren
f0f3cdad9c
fixup fromstring return types (#10162)
in https://github.com/certbot/certbot/pull/9124 we had the problem of
certbot-nginx's `Addr.fromstring` method possibly returning None which
is not possible in the `Addr` method in the certbot base class or in
certbot-apache. we fixed this by telling mypy the common
`Addr.fromstring` method returns an `Optional[Addr]` (despite it
actually always returning an `Addr`) and then unnecessarily complicating
certbot-apache's code a bit. the need for extra complexity with this
approach is going even further in
https://github.com/certbot/certbot/pull/10151 where we have to use
`cast` to assure mypy that the type isn't actually `Optional`. i
personally don't like all this
2025-01-28 16:29:52 -08:00
ohemorange
6f46e1be15
Improve help output for default-None constants (#10149)
Fixes #10000.

To create this PR, I looked through `constants.py` for defaults set to
`None`. If the action for the cli flag was `store_true` and there wasn't
other custom manual default specification, I changed it to report
`False`, and added a comment in `constants.py`. Adding `(default:` in
the help text suppresses listing of the actual default (done by
`cli_utils.py:CustomHelpFormatter`). Also added a comment for `redirect`
which is described manually since I noticed it while I was going
through.

---------

Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
2025-01-28 23:41:02 +00:00
ohemorange
ec3330ee0c
Enable strict typing in certbot-dns-digitalocean (#10158)
If we do `type: ignore` but don't set `--strict`, mypy gets mad. Flake8
doesn't like this but luckily we don't use that here (yet?). The other
option is to add `# type: ignore [method-assign, unused-ignore]`; I can
change it to that if that's preferred.

```
$ mypy --strict certbot-dns-digitalocean/certbot_dns_digitalocean
Success: no issues found in 5 source files
```
2025-01-28 11:04:08 -08:00
ohemorange
e657cc3a8d
[apache] Add type hints to apache parser.py (to enable mypy --strict) (#10152)
```
$ mypy --strict certbot-apache/certbot_apache/_internal/parser.py 
Success: no issues found in 1 source file
```

`typing.Pattern` is deprecated in python 3.9 in favor of using
`re.Pattern` directly, and also wants to be subscripted with its type.

`python-augeas` types can be found in
a1e84a7e58/augeas/__init__.py
2025-01-28 10:54:11 -08:00
ohemorange
a46db66371
Enable strict typing in certbot-dns-route53 (#10161)
Using the `ignore` syntax this time!

```
$ mypy --strict certbot-dns-route53/certbot_dns_route53
Success: no issues found in 5 source files
```
2025-01-28 10:53:27 -08:00
ohemorange
d98edd97ad
Preserve IP addresses when adding ssl listen directives in nginx server blocks (#10145)
Fixes #10011

When we take a server block with no ssl addresses in and and enable ssl,
if it has any listens on the http port, use those host addresses when
creating a directive to listen on ssl. Addresses with no port and on
other ports will be ignored.

---------

Co-authored-by: Will Greenberg <willg@eff.org>
2025-01-28 10:52:06 -08:00
ohemorange
70ba4f2438
Run directory hooks during commands other than renew (#10146)
Partially fixes #9869. Fixes #9978.
2025-01-28 10:20:17 -08:00
ohemorange
9d049723c2
Enable mypy strict equality checking (#10150)
Fixes one impossible check, but that's it! Closes
https://github.com/certbot/certbot/issues/5649.
2025-01-27 14:55:57 -08:00
ohemorange
60b88a3b83
[apache] Add type hints to apache dualparser.py (to enable mypy --strict) (#10153)
`typing.Type` is deprecated in favor of built-in `type`. In strict
mode,`find_ancestors` needs to be more specific about what it actually
returns, due to covariance and generics and such.

```
$ mypy --strict certbot-apache/certbot_apache/_internal/dualparser.py 
Success: no issues found in 1 source file
```
2025-01-27 14:54:40 -08:00
ohemorange
e0e81a97f2
Add new style of issue template (#10143)
Pasted from the old one. Maybe we can just rename it but this is what
github's web interface led me to create.

I want to make sure that they at least create the template so that they
read it. If they then choose to ignore it that's fine, but it should
always pop up. Basically I want to keep the old behavior. Open to
alternatives.

We could also play around with the new issue forms:
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms

Or label this one the "bug" template, and create a second one that is
blank but has the header text paragraph. I haven't seen a way to make
something appear in all templates, including the "blank" one, other than
just turning off blank templates.
2025-01-22 16:27:03 -08:00
Alex Gaynor
e050fe91a3
Allow using cryptography certs and keys in the standalone plugin (#10133)
Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
2025-01-16 22:16:45 +00:00
Will Greenberg
ed972a130f
Add gen_ss_cert deprecation to changelog (#10142)
Forgot a changelog note for this
2025-01-16 19:23:41 +00:00
Brad Warren
b411cddc8a
fix private key format (#10134)
fixes https://github.com/certbot/certbot/issues/10131

this seems simple enough, but i also requested alex's review as a quick
sanity check if he doesn't mind providing one

i've verified this fixes the problem and that PKCS#8 was used in certbot
3.0.1
2025-01-16 11:04:55 -08:00
Brad Warren
40f0b91512
Fix readlink on windows (#10140)
fixes https://github.com/certbot/certbot/issues/10135

i did this by first reverting the bad changes from
https://github.com/certbot/certbot/pull/10077 and then fixing up
comments/documentation

it seems that the code comments
[here](https://github.com/certbot/certbot/blob/v3.0.1/certbot/certbot/compat/filesystem.py#L410-L411)
and in the unit tests that os.readlink always returns the extended form
in python 3.8+ was incorrect

significant credit for this work goes to
https://github.com/certbot/certbot/pull/10136 and
https://github.com/mbs-c for identifying the problem in the code here
2025-01-16 10:09:44 -08:00
Will Greenberg
7e87acee3c
acme: deprecate gen_ss_cert in favor of make_self_signed_cert (#10097)
gen_ss_cert()'s signature contains deprecated pyOpenSSL API, so here we
deprecate it in favor of a new function that does the same thing, except
with only cryptography types: make_self_signed_cert
2025-01-16 11:38:10 +09:00
ohemorange
680729655e
Honor --reuse-key when --allow-subset-of-names is set (#10138)
Fixes #10109. We were not previously doing so, and that was an
oversight. Adds regression tests in unit tests and integration tests.

Integration regression test failing without the fix is here:
https://dev.azure.com/certbot/certbot/_build/results?buildId=8463&view=logs&j=fca58cec-e7ce-563a-f36f-5c233894d750&t=8c19ffdb-5db1-573e-d81e-907ba1b3cfee
2025-01-16 01:41:57 +00:00
Brad Warren
94dcf25f6e
notify about PRs from forks (#10101) 2025-01-15 17:19:25 -08:00
Brad Warren
96c4bcd9a8
double failing timeout (#10141)
our macOS tests recently started failing (more?) often hitting the
timeout modified in this PR. an example of this can be seen at
https://dev.azure.com/certbot/certbot/_build/results?buildId=8459&view=logs&j=1ae398a1-7dc9-5ade-0f59-912b32975b53&t=0ec28dfb-4593-5e04-05b6-bb502ec0a017&s=96ac2280-8cb4-5df5-99de-dd2da759617d.
this has affected at least
https://github.com/certbot/certbot/pull/10138,
https://github.com/certbot/certbot/pull/10130, and
https://github.com/certbot/certbot/pull/10136

i'm not sure whether the failing tests are actually getting stuck or
just hitting the timeout i bumped here, but i suspect it may be the
latter. our tests on macOS in CI are unreasonably slow for some reason.
i do not have this problem on my macbook locally

this PR does the simple/lazy thing of bumping the timeout which may help
avoid the now regularly occuring problem and/or help us get more
certainty whether the tests are actually getting stuck or not
2025-01-15 13:51:02 -08:00
Brad Warren
a00e343459
update policy on minimum dependency versions (#10130)
fixes #10105

this PR updates our minimally required cryptography and pyopenssl
versions as well as updating our policy for choosing minimum dependency
versions generally

before this PR, we were trying to keep compatibility with packages
available in EPEL 9 using the python 3 version available in RHEL 9.
after the discussion in #10105 we decided not to do this anymore
because:

* EPEL 9 may not want to update to certbot 3.0+ anyway because of our
backwards incompatible changes from certbot 2.x
* RHEL 9 appstream repos now contain newer versions of many of our
dependencies for newer versions of python
* alternate installation methods for RHEL 9 based users including our
snaps and pip are available

on a call we then discussed what distro repositories we should track
instead of EPEL 9. our docs previously said Debian sid/unstable, but we
felt this as unnecessary because Debian sid can and does change very
quickly. if we wanted a new dependency there, Debian could probably
accommodate it

we also considered RHEL 10 + EPEL 10, however, these repos are not even
stable yet and certbot and many of its dependencies are not yet packaged
there at all

for these reasons, plus many of the reasons we decided to upgrade past
EPEL 9 with the default python 3 version there, we decided that at least
for now, we will remove any linux distro considerations when choosing
minimal dependency versions of certbot

as i wrote in the contributing docs, we may choose to reconsider this
plan if there are requests for us to do so, but based on the information
above, we are not sure this will ever even happen and removing this
constraint significantly simplifies development of certbot
2025-01-15 09:47:40 -08:00
Alexis
86694397a6
Update notify_weekly.yaml (#10118)
Making the weekly message a little more useful.

---------

Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
2025-01-13 07:46:12 -08:00
ohemorange
b18c074088
Allow non-breaking spaces in nginx config files (#10126)
Fixes @josevavia's issue in #9942.
2025-01-10 15:25:05 -08:00
Brad Warren
f59a639ec4
improve repin experience on macOS (#10128)
this hopefully at least helps the problem hit at
https://github.com/certbot/certbot/pull/10126#discussion_r1909714276

i took this approach because in my experience, linux specific shell
commands have crept into our scripts repeatedly over the years so i
think just having macOS devs use the linux versions is much more
reliable. it's what i've personally been doing for years now
2025-01-10 12:54:54 -08:00
Brad Warren
5411e4c86a
silence poetry warning (#10127)
when reviewing https://github.com/certbot/certbot/pull/10126 and running
`tools/pinning/oldest/repin.sh` using a freshly created dev environment,
i was repeatedly given the message

> The "poetry.dev-dependencies" section is deprecated and will be
removed in a future version. Use "poetry.group.dev.dependencies"
instead.

i believe this section was generated automatically by poetry's tooling
when it created the initial boilerplate file for us, but we don't use
it, so i just deleted the section which makes the warnings disappear
2025-01-10 12:52:24 -08:00
Brad Warren
0425b87b78
Merge pull request #10123 from certbot/candidate-3.1.0
Release Certbot 3.1.0
2025-01-07 15:53:09 -08:00
Erica Portnoy
1de966d637 Bump version to 3.2.0 2025-01-07 12:54:01 -08:00
Erica Portnoy
ba2e4aecb7 Add contents to certbot/CHANGELOG.md for next version 2025-01-07 12:54:01 -08:00
Erica Portnoy
7d2b1996d9 Remove built packages from git 2025-01-07 12:54:01 -08:00
Erica Portnoy
dcd52b0711
Release 3.1.0 2025-01-07 12:54:00 -08:00
Erica Portnoy
8074858620 Update changelog for 3.1.0 release 2025-01-07 12:53:36 -08:00
Brad Warren
d3d293299a
minor acme doc & comment fixes (#10122)
this fixes two tiny things i noticed when reviewing
https://github.com/certbot/certbot/pull/10120

1. not all of our `acme` modules were generating API documentation
2. the deleted commend about a "type ignore" should have been deleted in
https://github.com/certbot/certbot/pull/9197 but will and i missed it
2025-01-07 18:17:00 +00:00
Alex Gaynor
9148acd332
Migrate verify_cert to take cryptography certificates (#10120) 2025-01-07 17:46:31 +00:00
Brad Warren
9f9a1df85e
upgrade pylint (#10121)
we need this for https://github.com/certbot/certbot/issues/10045
2025-01-07 09:43:14 -08:00
ohemorange
985457e57b
Add docstring for acme.crypto_util.get_names_from_subject_and_extensions (#10115)
It was my oversight to not request this when this function was made
public in https://github.com/certbot/certbot/pull/10111.
2025-01-06 14:37:29 -08:00
Alex Gaynor
4004589cbf
Migrate certbot-compatibility-test to cryptography (as much as possible (#10117)
Also fixed a typing error.
2025-01-06 13:39:16 -08:00
Alex Gaynor
8f7c3756b3
Migrate get_serial_from_cert and valid_privkey to cryptography (#10116) 2025-01-06 13:34:57 -08:00
Alex Gaynor
6ea5da51e0
Simplify typing for a local variable (#10113)
`_DefaultCertSelection` _is_ a `Callable` of the appropriate signature.

Also fixed a mypy error I see locally, `TOKEN_SIZE` should be an
integer.
2025-01-06 13:18:28 -08:00
Alex Gaynor
1ac05ae891
Remove _pyopenssl_cert_or_req_san_ip which is unused, and migrate _pyopenssl_cert_or_req_all_names to cryptography (#10112)
Unfortunately the other helpers from this family are directly called by
(historic) versions of certbot, and so cannot be easily removed.
2025-01-06 12:46:23 -08:00
Manuel Baldassarri
a441debdaa
Add Nginx Unit plugin to documentation (#10110)
## Pull Request Checklist

- [ ] The Certbot team has recently expressed interest in reviewing a PR
for this. If not, this PR may be closed due our limited resources and
need to prioritize how we spend them.
- [ ] If the change being made is to a [distributed
component](https://certbot.eff.org/docs/contributing.html#code-components-and-layout),
edit the `main` section of `certbot/CHANGELOG.md` to include a
description of the change being made.
- [x] Add or update any documentation as needed to support the changes
in this PR.
- [ ] Include your name in `AUTHORS.md` if you like.
2025-01-06 12:37:31 -08:00
Alex Gaynor
5dd898f56b
Move _get_names_from_subject_and_extensions to acme's crypto_utils (#10111)
Make use of it in more places
2025-01-03 16:21:31 -08:00
Alex Gaynor
a1fce6b398
Convert notBefore and notAfter to use cryptography's APIs (#10103) 2025-01-03 13:50:33 -08:00
Will Greenberg
635d9c3ec3
Merge pull request #10090 from alex/san-cryptography
Convert several SAN handling functions to use cryptography's APIs
2025-01-02 11:42:49 -08:00
Alex Gaynor
0f36d0c1ba Convert several SAN handling functions to use cryptography's APIs 2025-01-02 14:25:17 -05:00
Alex Gaynor
619da0432a Introduce a Format enum to help us migrate away from pyOpenSSL's constants
Begin using it in `dump_pyopenssl_chain`
2024-12-21 11:06:43 -05:00
Alex Gaynor
314838eb81
Convert some certbot-ci utilities to use cryptography's APIs (#10102) 2024-12-19 19:37:09 +00:00
Will Greenberg
25a1933e01
snap: disable FIPS detection (#10067)
This is needed because the Python + OpenSSL bundled in core24 don't
include an OpenSSL FIPS provider, which causes crashes on host systems
with OpenSSL 1.1.1f (e.g. Ubuntu Pro 20.04). For some reason, core24's
OpenSSL also looks in a non-standard location for the provider, which
also causes crashes on systems with OpenSSL 3.x (e.g. RHEL 9). If you
need FIPS functionality in certbot, install via pip.
2024-12-19 10:55:53 -08:00
Alex Gaynor
0f500e8010
Convert crypto_util_test.py to use cryptography's APIs (#10100) 2024-12-19 10:24:16 -08:00
Alex Gaynor
1afae838bb
Convert validate_key_csr to use cryptography's APIs (#10099) 2024-12-19 07:11:47 -08:00
Alex Gaynor
724be8848a
Convert http01_example.py to use cryptography's APIs (#10098)
Co-authored-by: ohemorange <ebportnoy@gmail.com>
2024-12-18 23:54:44 +00:00
Alex Gaynor
06ea141ca9
Convert make_key to use cryptography's APIs (#10091) 2024-12-18 15:10:20 -08:00