Skip to content

Don't ignore SSLOptions when GNU TLS has no SYSTEM priority - #234

Merged
michaelrsweet merged 3 commits into
OpenPrinting:masterfrom
rue19:gnutls-system-priority
Nov 25, 2026
Merged

michaelrsweet merged 3 commits into
OpenPrinting:masterfrom
rue19:gnutls-system-priority

Conversation

@rue19

@rue19 rue19 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Split out of #232 as requested.

_httpTLSStart builds the GNU TLS priority string as @SYSTEM,NORMAL:.... GNU TLS only accepts @SYSTEM when its configuration file defines a SYSTEM priority, and Debian and Ubuntu don't define one. The whole string is rejected, the return value is ignored, and the session keeps the defaults from gnutls_set_default_priority. So every SSLOptions setting (MinTLS*, MaxTLS*, DenyCBC, ...) is silently dropped.

This is the same bug as OpenPrinting/cups#1677, which was fixed in CUPS by OpenPrinting/cups#1701. This PR mirrors that fix:

  • Probe @SYSTEM first and only prepend it when it is available (both the gnutls_priority_set_direct and gnutls_priority_init code paths).
  • Check the result of setting the priorities and fail the connection instead of continuing with the defaults.

The C change is identical to the CUPS one.

Tested on Ubuntu 26.04 (GNU TLS 3.8.12, stock /etc/gnutls/config, no [priorities]), built with the CI flags (--enable-debug --enable-maintainer --with-tls=gnutls --with-sanitizer=address):

  • tlscheck --tls12 against a server that offers TLS 1.3: master connects with TLS/1.3; with this PR it connects with TLS/1.2.
  • A local (not committed) port of testssloptions.py from Fix ignored GnuTLS options when SYSTEM priorities are unavailable cups#1701: 3 failures on master (MaxTLS1.2 gives TLS 1.3, a TLS 1.3-only server is accepted, MinTLS1.3 accepts TLS 1.2). 8/8 pass with this PR, using both gnutls_priority_set_direct and the gnutls_priority_init fallback (built with HAVE_GNUTLS_PRIORITY_SET_DIRECT undefined).
  • make test passes.

The priority string started with "@System,", which GNU TLS only accepts
when its configuration file defines a SYSTEM priority.  Debian and Ubuntu
do not, so the whole string was rejected, the error was ignored, and the
session kept the default priorities - every SSLOptions setting (MinTLS,
MaxTLS, DenyCBC, ...) was silently dropped.

Mirror the fix from CUPS (OpenPrinting/cups#1677, #1701): probe "@System"
before using it, and fail the connection if the priorities cannot be set.
Port test/testssloptions.py from CUPS (OpenPrinting/cups#1701) to the
libcups 3 API.  It builds a small client with the flags from Makedefs,
runs it against local Python TLS servers with and without a SYSTEM
priority, and checks that the SSLOptions in client.conf are honored.

Like in CUPS it is only run by the GNU TLS job in build.yml, so the build
system does not depend on Python.
@michaelrsweet michaelrsweet self-assigned this Nov 25, 2026
@michaelrsweet michaelrsweet added bug Something isn't working platform issue Issue is specific to an OS or desktop labels Nov 25, 2026
@michaelrsweet michaelrsweet added this to the Stable milestone Nov 25, 2026

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the python tests. Python isn't particularly portable and I have no desire to maintain such a test framework going forward.

The tls-gnutls.c changes are fine.

Python isn't portable enough for the libcups test suite.
@rue19

rue19 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, I've removed the Python test and the CI step. The PR now only changes cups/tls-gnutls.c.

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@michaelrsweet
michaelrsweet merged commit 9aef120 into OpenPrinting:master Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working platform issue Issue is specific to an OS or desktop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants