Commit graph

14 commits

Author SHA1 Message Date
ohemorange
b362109bf6
Fix certbot tests after updating pytest to 9.0.2 (#10545)
Fixes  #10518.

`tools/pinning/current/repin.sh` is not run; only pytest version is
updated. This is because `pypinning` had a bunch of syntax changes that
seem simply but I believe should be in a separate PR, which I think
should be done after this to collect all repin changes.

As discussed further in #10518, these issues were caused by pytest's
internalization of pytest-subtest, which had several implementation
changes.

To fix these, we simply no longer use subtest in the failing tests. The
test in acme is now parametrized instead, and the tests in apache only
ever had a single parameter.

To use parametrization in the acme test, I converted `DNSTest` from
unittest to pytest style, which was pretty straightforward. The only
note there is that while it would be nice to make `ec_secp384r1_key` a
fixture, you [can't use fixtures in
parameters](https://github.com/pytest-dev/pytest/issues/349). You could
use requests, but that seemed less clear and messier, because then you'd
be checking the value of the parameter and only sometimes loading it.
Could also make it a global variable, but that didn't really seem
necessary, as it's only called twice. Happy to consider other options,
not strongly tied to this one, just seemed nicest to me.
2026-02-02 12:13:24 -08:00
Jacob Hoffman-Andrews
58724f68ec
Add CLI flag --ip-address (#10495)
Co-authored-by: ohemorange <ebportnoy@gmail.com>
Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
2026-01-16 13:23:41 -08:00
Jacob Hoffman-Andrews
b1cf53ff6b
Add identifier field to AnnotatedChallenge subclasses (#10491)
This field is optional to maintain backwards compatibility. Note that
`AnnotatedChallenge` inherits from `jose.ImmutableMap`, which has a
[check in
__init__](4b74747670/src/josepy/util.py (L125-L131))
that all slots are provided. That check would not allow us to do a
backwards-compatible addition, so I implemented an `__init__` for each
of these subclasses that fills the fields without calling the parent
`__init__`, and so doesn't hit an error when `identifier` is absent.

I chose to use `acme.messages.Identifier` rather than
`certbot._internal.san.SAN` here because these are wrapped ACME types,
so they should use the ACME representation. Also, `AnnotatedChallenge`
is passed to plugins, so we need to pass a type that the plugins can
understand.

Additionally, `domain` is marked as deprecated.

Part of #10346

/cc @bmw, who noticed the issue with `AnnotatedChallenge`
[here](https://github.com/certbot/certbot/pull/10468#issuecomment-3403294394)
and provided additional feedback
[here](https://github.com/jsha/certbot/pull/2#issuecomment-3534895793).
Note that there's still some work to do to finish excising `domain`
assumptions from this portion of the code.

---------

Co-authored-by: ohemorange <ebportnoy@gmail.com>
2025-12-05 13:44:04 -08:00
Jason Owen
6e489cdb74
Remove vhost_combined override from Apache conf (#10486)
The Apache configuration `Include`d in automatically created
`[sitename]-le-ssl.conf` files was redefining the `vhost_combined`
`LogFormat`, but contrary to the comment before the redefinition, did
not include the virtual host server name in the log format. This is
particularly confusing because this redefinition is hard to find when
debugging logging issues, as log formats are not related to SSL/TLS
configuration, and the included configuration file is outside of
`/etc/apache2`.

Additionally, a `vhost_common` `LogFormat` was defined, but not used
anywhere.

The `LogFormat` directives were introduced in commit
68f85d9f1a. Several other directives that
do not directly pertain to configuring SSL/TLS were added in that
commit, and have gradually been removed over the years. This should be
the last such removal.

Delete the `LogFormat` directives from the Apache configuration files
(both old and current), and update the `ALL_SSL_OPTIONS_HASHES`.

Fixes #9769 File 'options-ssl-apache.conf' included in autocreated
'[sitename]-le-ssl.conf' has potentially problematic vhost_combined
LogFormat
2025-11-26 09:03:31 -08:00
ohemorange
5c30a180a2
Apache config update (#10443)
Part of https://github.com/certbot/certbot/issues/10183

There are two changes made here:

1. Add `DHE-RSA-CHACHA20-POLY1305` to `SSLCipherSuite` list. Nice to
have for compliance reasons. See
https://github.com/mozilla/server-side-tls/issues/285 DHE ciphers in
general are the topic of
[some](https://github.com/mozilla/server-side-tls/issues/268)
[debate](https://github.com/mozilla/server-side-tls/issues/299) over on
the generator repo; my opinion is that certbot should match whatever
they currently recommend, and if they do decide to change it, we can
also update to match them again later.
2. Configure curves with `SSLOpenSSLConfCmd`. Needed for OpenSSL 3.0
support, so FFDH won't be used. This option requires apache `>=2.4.8`
but we already require `>=2.4.11` to use this conf file in the first
place, so that's fine. When the file in their repo was converted from
`.hbs` to `.js` the version requirement was changed to `>=2.4.11` but I
suspect that's a bug, and either way it's still fine. See
https://github.com/mozilla/ssl-config-generator/issues/270 and
https://github.com/mozilla/ssl-config-generator/pull/297

You can see a generated Apache config file here:
https://ssl-config.mozilla.org/#server=apache&version=2.4.60&config=intermediate&openssl=3.4.0&guideline=5.7

Originally, I had planned to switch `SSLProtocol` list to allowlist
format. It's a little nicer, though it did the same thing, technically,
and would let us match mozilla, who does this because it makes their
code cleaner. See
https://github.com/mozilla/ssl-config-generator/pull/286/. But TLSv1.3
is only
[supported](https://github.com/mozilla/ssl-config-generator/blob/master/src/js/configs.js#L12C5-L12C21)
in `apache >= 2.4.36`, so we on the other hand would have to include it
conditionally. Whereas despite `SSLv2` [not being
available](https://github.com/mozilla/ssl-config-generator/pull/286/files#diff-3d067ee1b10453909ca9c86397a6b235fcb961ed3ca1cfbdda4daa2cb4b30b97L41)
in `apache >= 2.3.16`, it still recognizes it just fine in a config.
We're always `>= 2.3.16` now so we could remove it proactively, I
suppose, in case apache stops recognizing it. I left it as-is here but
could change it.
2025-08-27 16:38:08 -07:00
Brad Warren
444e3251bf
make apache tls warning conditional (#10444)
this is in response to the thread at
https://opensource.eff.org/eff-open-source/pl/49gnrcner7gptrnsi339bqu1yo
2025-08-25 10:19:18 -07:00
ohemorange
56da12207b
Mock time.sleep for more modules to speed up tests (#10427)
The extra 8 seconds isn't really relevant in the test farm, but is nice
to have for local runs. This is based on what was done in
https://github.com/certbot/certbot/pull/10419/.
2025-08-18 09:59:55 -07:00
ohemorange
454048f2f6
Fix memory leak in apache unit tests (#10421)
This was causing oldest tests to fail on my mac, which has an open file
limit of 256. Locks were being released at exit, but there were more
than 256 tests being run at once. Holding onto the file descriptor for
temporary files was making us keep the files open.

I also removed unnecessary setUps and tearDowns in subclasses so that
this could be fixed in only one spot.

If you wanted to do any testing locally, I was throwing this in places:
```
import errno, os, resource
open_file_handles = []
for fd in range(resource.getrlimit(resource.RLIMIT_NOFILE)[0]):
    try: os.fstat(fd)
    except OSError as e:
        if e.errno == errno.EBADF: continue
    open_file_handles.append(fd)
print(f'location description: {len(open_file_handles)}')
```
2025-08-14 17:13:33 -07:00
Brad Warren
27b344c8d8
use pep585 types in certbot-apache (#10413)
this is another part of https://github.com/certbot/certbot/issues/10195

these changes were done automatically with the command:

```
ruff check --fix --extend-select UP006 --unsafe-fixes certbot-apache
```
2025-08-12 15:36:02 -07:00
ohemorange
dea3e5f1c4
Set up ruff so that test files have at least some linting (#10399)
Alternative implementation for #7908.

In this PR:
- set up ruff in CI (add to `tox.ini`, mark dep in `certbot/setup.py`)
- add a `ruff.toml` that ignores particularly annoying errors. I think
line length isn't actually necessary to set with this workflow since
we're not checking it but putting it there for future usage.
- either fix or ignore the rest of the errors that come with the default
linting configuration. fixed errors are mostly unused variables. ignored
are usually where we're doing weird import things for a specific reason.
2025-08-08 08:48:43 -07:00
ohemorange
5859e50e44
Run ruff to fix test errors (#10398)
This is mostly removing unused imports, plus one unused `import as`. Had
to put back imports being used with `eval` -- see the second commit.
2025-08-07 22:10:02 +00:00
ohemorange
d8acf7cea0
Add note and warning about old-options-ssl-apache.conf not receiving updates (#10373)
Part of #10183

> Option 4. Stop updating old files with security improvements. If
people want to be on old software they can but then they're not getting
the nice new things. We can either warn or not warn if we see people
using them, either on certbot install (what, who's installing new
certbot on these machines), new cert, cert renewal, or certbot update.
The second two would require code changes, I'm pretty sure. I don't
think we should warn too often because that's how we get people to
silence all output. This is a little weird because we don't usually keep
around deprecated things. We could also warn loudly and see if people
complain. Or do some sort of brownout.

This PR warns every time certbot is run. We could make it run less often
(only when a new config file is installed, probably), but that's a more
extensive code change, and honestly I think it's probably fine? But I
can change it.
2025-07-25 12:05:58 -07:00
Yaroslav Halchenko
86f76cd3df
Add codespell support (CI to check, not to fix) and make it fix a few typos (#10297)
Another token of gratitude for a super useful tool and service.

More about codespell: https://github.com/codespell-project/codespell .

I personally introduced it to dozens if not hundreds of projects already
and so far only positive feedback.

CI workflow has 'permissions' set only to 'read' so also should be safe.

---------

Signed-off-by: Yaroslav O. Halchenko <debian@onerussian.com>
2025-06-24 13:14:31 +09:00
ohemorange
16f858547f
Add --use-pep517 flag to pip to silence warning in tools/venv.py, and switch codebase to src-layout (#10249)
Fixes #10252.

See further discussion here: https://github.com/pypa/pip/issues/11457

We are doing option:

> Alternatively, enable the --use-pep517 pip option, possibly with
--no-build-isolation. The --use-pip517 flag will force pip to use the
modern mechanism for editable installs. --no-build-isolation may be
needed if your project has build-time requirements beyond setuptools and
wheel. By passing this flag, you are responsible for making sure your
environment already has the required dependencies to build your package.
Once the legacy mechanism is removed, --use-pep517 will have no effect
and will essentially be enabled by default in this context.

Major changes made here include:
- Add `--use-pep517` to use the modern mechanism, which will be the only
mechanism in future pip releases
- Change to `/src` layout to appease mypy, and because for editable
installs that really is the normal way these days.
  - `cd acme && mkdir src && mv acme src/` etc.
- add `where='src'` argument to `find_packages` and add
`package_dir={'': 'src'},` in `setup.py`s
  - update `MANIFEST.in` files with new path locations 
- Update our many hardcoded filepaths
- Update `importlib-metadata` requirement to fix
double-plugin-entry-point problem in oldest tests
2025-04-11 19:30:33 +00:00