From 17c80ddacfa79cfd1925ce6457e949f9d6cfa510 Mon Sep 17 00:00:00 2001
From: rue19
Date: Tue, 24 Nov 2026 16:54:23 +0530
Subject: [PATCH] Add DenyRSA and DenyECC SSLOptions (Issue #163)
The new options limit the certificate/signature algorithms used to
authenticate TLS connections, so that RSA and/or ECC can be disabled in
favor of post-quantum (ML-DSA) certificates:
- OpenSSL: filter aRSA/aECDSA cipher suites for TLS/1.2 and set the
signature algorithm list (which also covers TLS/1.3). ML-DSA is
included with OpenSSL 3.5 and later. LibreSSL has no way to set the
signature algorithms, so the options cause the connection to fail
there rather than being silently ignored.
- GNU TLS: remove the RSA/ECDSA key exchanges and signature algorithms
from the priority string.
- Auto-created server credentials use ECDSA P-384 when RSA is denied,
and fail with an error when both are denied.
- tlscheck gets matching --no-rsa and --no-ecc options.
Key exchange is not changed: OpenSSL 3.5 already negotiates the hybrid
X25519MLKEM768 group by default.
---
cups/http-private.h | 2 ++
cups/tls-gnutls.c | 31 ++++++++++++++++++++++++++--
cups/tls-openssl.c | 48 +++++++++++++++++++++++++++++++++++++++++++-
cups/tls.c | 38 +++++++++++++++++++++++++++++++++++
cups/tlscheck.c | 10 +++++++++
cups/usersys.c | 8 ++++++--
doc/client.conf.html | 10 ++++++++-
man/client.conf.5 | 10 ++++++++-
8 files changed, 150 insertions(+), 7 deletions(-)
diff --git a/cups/http-private.h b/cups/http-private.h
index 1e0266765..935eb209d 100644
--- a/cups/http-private.h
+++ b/cups/http-private.h
@@ -61,6 +61,8 @@ extern "C" {
# define _HTTP_TLS_ALLOW_DH 2 // Allow DH/DHE key negotiation
# define _HTTP_TLS_DENY_CBC 4 // Deny CBC cipher suites
# define _HTTP_TLS_NO_SYSTEM 8 // No system crypto policy
+# define _HTTP_TLS_DENY_RSA 16 // Deny RSA certificates/signatures
+# define _HTTP_TLS_DENY_ECC 32 // Deny ECDSA/EdDSA certificates/signatures
# define _HTTP_TLS_SET_DEFAULT 128 // Setting the default TLS options
# define _HTTP_TLS_SSL3 0 // Min/max version is SSL/3.0
diff --git a/cups/tls-gnutls.c b/cups/tls-gnutls.c
index ad6a70ac9..d4bdd3f8f 100644
--- a/cups/tls-gnutls.c
+++ b/cups/tls-gnutls.c
@@ -1807,9 +1807,11 @@ _httpTLSStart(http_t *http) // I - Connection to server
if (!have_creds && tls_auto_create && cn)
{
+ cups_credtype_t credtype; // Type of credentials to create
+
DEBUG_printf("4_httpTLSStart: Auto-create credentials for \"%s\".", cn);
- if (!cupsCreateCredentials(tls_keypath, false, CUPS_CREDPURPOSE_SERVER_AUTH, CUPS_CREDTYPE_DEFAULT, CUPS_CREDUSAGE_DEFAULT_TLS, NULL, NULL, NULL, NULL, NULL, cn, /*email*/NULL, 0, NULL, NULL, time(NULL) + 3650 * 86400))
+ if (!http_default_credtype(&credtype) || !cupsCreateCredentials(tls_keypath, false, CUPS_CREDPURPOSE_SERVER_AUTH, credtype, CUPS_CREDUSAGE_DEFAULT_TLS, NULL, NULL, NULL, NULL, NULL, cn, /*email*/NULL, 0, NULL, NULL, time(NULL) + 3650 * 86400))
{
DEBUG_printf("4_httpTLSStart: cupsCreateCredentials failed: %s", cupsGetErrorString());
http->error = errno = EINVAL;
@@ -1900,8 +1902,33 @@ _httpTLSStart(http_t *http) // I - Connection to server
if (tls_options & _HTTP_TLS_DENY_CBC)
cupsConcatString(priority_string, ":!AES-128-CBC:!AES-256-CBC:!CAMELLIA-128-CBC:!CAMELLIA-256-CBC:!3DES-CBC", sizeof(priority_string));
+ if (tls_options & _HTTP_TLS_DENY_RSA)
+ {
+ // Disable RSA key exchange/authentication and RSA signatures...
+ cupsConcatString(priority_string, ":-RSA:-DHE-RSA:-ECDHE-RSA:-SIGN-RSA-SHA1:-SIGN-RSA-SHA224:-SIGN-RSA-SHA256:-SIGN-RSA-SHA384:-SIGN-RSA-SHA512", sizeof(priority_string));
+# if GNUTLS_VERSION_NUMBER >= 0x03060c
+ cupsConcatString(priority_string, ":-SIGN-RSA-PSS-SHA256:-SIGN-RSA-PSS-SHA384:-SIGN-RSA-PSS-SHA512:-SIGN-RSA-PSS-RSAE-SHA256:-SIGN-RSA-PSS-RSAE-SHA384:-SIGN-RSA-PSS-RSAE-SHA512", sizeof(priority_string));
+# endif // GNUTLS_VERSION_NUMBER >= 0x03060c
+ }
+
+ if (tls_options & _HTTP_TLS_DENY_ECC)
+ {
+ // Disable ECDSA authentication and ECDSA/EdDSA signatures...
+ cupsConcatString(priority_string, ":-ECDHE-ECDSA:-SIGN-ECDSA-SHA1:-SIGN-ECDSA-SHA224:-SIGN-ECDSA-SHA256:-SIGN-ECDSA-SHA384:-SIGN-ECDSA-SHA512", sizeof(priority_string));
+# if GNUTLS_VERSION_NUMBER >= 0x03060c
+ cupsConcatString(priority_string, ":-SIGN-ECDSA-SECP256R1-SHA256:-SIGN-ECDSA-SECP384R1-SHA384:-SIGN-ECDSA-SECP521R1-SHA512:-SIGN-EDDSA-ED25519:-SIGN-EDDSA-ED448", sizeof(priority_string));
+# endif // GNUTLS_VERSION_NUMBER >= 0x03060c
+ }
+
+ DEBUG_printf("4_httpTLSStart: priority_string=\"%s\"", priority_string);
+
#ifdef HAVE_GNUTLS_PRIORITY_SET_DIRECT
- gnutls_priority_set_direct(http->tls, priority_string, NULL);
+ {
+ const char *priority_error = NULL; // Location of priority string error
+
+ if ((status = gnutls_priority_set_direct(http->tls, priority_string, &priority_error)) != GNUTLS_E_SUCCESS)
+ DEBUG_printf("4_httpTLSStart: gnutls_priority_set_direct returned %d (%s) at \"%s\"", status, gnutls_strerror(status), priority_error ? priority_error : "");
+ }
#else
gnutls_priority_t priority; // Priority
diff --git a/cups/tls-openssl.c b/cups/tls-openssl.c
index 27f4d5e80..dba4674fe 100644
--- a/cups/tls-openssl.c
+++ b/cups/tls-openssl.c
@@ -1915,9 +1915,11 @@ _httpTLSStart(http_t *http) // I - Connection to server
if (!have_creds && tls_auto_create && cn)
{
+ cups_credtype_t credtype; // Type of credentials to create
+
DEBUG_printf("4_httpTLSStart: Auto-create credentials for \"%s\".", cn);
- if (!cupsCreateCredentials(tls_keypath, false, CUPS_CREDPURPOSE_SERVER_AUTH, CUPS_CREDTYPE_DEFAULT, CUPS_CREDUSAGE_DEFAULT_TLS, NULL, NULL, NULL, NULL, NULL, cn, NULL, 0, NULL, NULL, time(NULL) + 3650 * 86400))
+ if (!http_default_credtype(&credtype) || !cupsCreateCredentials(tls_keypath, false, CUPS_CREDPURPOSE_SERVER_AUTH, credtype, CUPS_CREDUSAGE_DEFAULT_TLS, NULL, NULL, NULL, NULL, NULL, cn, NULL, 0, NULL, NULL, time(NULL) + 3650 * 86400))
{
DEBUG_printf("4_httpTLSStart: cupsCreateCredentials failed: %s", cupsGetErrorString());
http->error = errno = EINVAL;
@@ -1958,6 +1960,10 @@ _httpTLSStart(http_t *http) // I - Connection to server
cupsConcatString(cipherlist, ":!RC4", sizeof(cipherlist));
if (tls_options & _HTTP_TLS_DENY_CBC)
cupsConcatString(cipherlist, ":!SHA1:!SHA256:!SHA384", sizeof(cipherlist));
+ if (tls_options & _HTTP_TLS_DENY_RSA)
+ cupsConcatString(cipherlist, ":!aRSA", sizeof(cipherlist));
+ if (tls_options & _HTTP_TLS_DENY_ECC)
+ cupsConcatString(cipherlist, ":!aECDSA", sizeof(cipherlist));
cupsConcatString(cipherlist, ":@STRENGTH", sizeof(cipherlist));
DEBUG_printf("4_httpTLSStart: cipherlist='%s', tls_min_version=%d, tls_max_version=%d", cipherlist, tls_min_version, tls_max_version);
@@ -1966,6 +1972,46 @@ _httpTLSStart(http_t *http) // I - Connection to server
SSL_CTX_set_max_proto_version(context, versions[tls_max_version]);
SSL_CTX_set_cipher_list(context, cipherlist);
+ if (tls_options & (_HTTP_TLS_DENY_RSA | _HTTP_TLS_DENY_ECC))
+ {
+ // Limit the signature algorithms used for authentication. The cipher
+ // list above only covers TLS/1.2 and earlier; TLS/1.3 negotiates the
+ // certificate/signature type separately. LibreSSL does not support
+ // setting the signature algorithms, so fail rather than silently
+ // allowing RSA/ECC with TLS/1.3...
+ bool ok = false; // Were the signature algorithms set?
+
+# ifdef SSL_CTX_set1_sigalgs_list
+ char sigalgs[512] = ""; // List of signature algorithms
+
+# if OPENSSL_VERSION_NUMBER >= 0x30500000L
+ cupsConcatString(sigalgs, ":mldsa65:mldsa87:mldsa44", sizeof(sigalgs));
+# endif // OPENSSL_VERSION_NUMBER >= 0x30500000L
+ if (!(tls_options & _HTTP_TLS_DENY_ECC))
+ cupsConcatString(sigalgs, ":ecdsa_secp256r1_sha256:ecdsa_secp384r1_sha384:ecdsa_secp521r1_sha512:ed25519:ed448", sizeof(sigalgs));
+ if (!(tls_options & _HTTP_TLS_DENY_RSA))
+ cupsConcatString(sigalgs, ":rsa_pss_rsae_sha256:rsa_pss_rsae_sha384:rsa_pss_rsae_sha512:rsa_pss_pss_sha256:rsa_pss_pss_sha384:rsa_pss_pss_sha512:rsa_pkcs1_sha256:rsa_pkcs1_sha384:rsa_pkcs1_sha512", sizeof(sigalgs));
+
+ DEBUG_printf("4_httpTLSStart: sigalgs='%s'", sigalgs);
+
+ ok = sigalgs[0] && SSL_CTX_set1_sigalgs_list(context, sigalgs + 1);
+# endif // SSL_CTX_set1_sigalgs_list
+
+ if (!ok)
+ {
+ // No allowed signature algorithms...
+ DEBUG_puts("4_httpTLSStart: No allowed signature algorithms.");
+ _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, _("No allowed signature algorithms."), true);
+
+ http->status = HTTP_STATUS_ERROR;
+ http->error = EINVAL;
+
+ SSL_CTX_free(context);
+
+ return (false);
+ }
+ }
+
// Setup a TLS session
cupsMutexLock(&tls_mutex);
if (!tls_bio_method)
diff --git a/cups/tls.c b/cups/tls.c
index 0aa1d3cb4..2ee6cf088 100644
--- a/cups/tls.c
+++ b/cups/tls.c
@@ -51,6 +51,7 @@ static int tls_options = -1,// Options for TLS connections
//
static char *http_copy_file(const char *path, const char *common_name, const char *ext);
+static bool http_default_credtype(cups_credtype_t *type);
static const char *http_default_path(char *buffer, size_t bufsize);
static bool http_default_san_cb(const char *common_name, const char *subject_alt_name, void *data);
#if defined(_WIN32) || defined(HAVE_GNUTLS)
@@ -365,6 +366,43 @@ http_copy_file(const char *path, // I - Directory
}
+//
+// 'http_default_credtype()' - Get the key type for auto-created server credentials.
+//
+// The type is chosen so that the server can still negotiate when the
+// "DenyRSA" or "DenyECC" SSLOptions are in effect.
+//
+
+static bool // O - `true` on success, `false` if no allowed type
+http_default_credtype(
+ cups_credtype_t *type) // O - Credential type
+{
+ int options = tls_options < 0 ? _HTTP_TLS_NONE : tls_options;
+ // TLS options
+
+
+ if ((options & _HTTP_TLS_DENY_RSA) && (options & _HTTP_TLS_DENY_ECC))
+ {
+ // No traditional key type is allowed...
+ *type = CUPS_CREDTYPE_DEFAULT;
+ _cupsSetError(IPP_STATUS_ERROR_CUPS_PKI, _("No allowed key type for server credentials."), true);
+ return (false);
+ }
+ else if (options & _HTTP_TLS_DENY_RSA)
+ {
+ // Use ECDSA...
+ *type = CUPS_CREDTYPE_ECDSA_P384_SHA256;
+ }
+ else
+ {
+ // Use the default (RSA) type...
+ *type = CUPS_CREDTYPE_DEFAULT;
+ }
+
+ return (true);
+}
+
+
//
// 'http_default_path()' - Get the default credential store path.
//
diff --git a/cups/tlscheck.c b/cups/tlscheck.c
index 0a07b492c..756a23108 100644
--- a/cups/tlscheck.c
+++ b/cups/tlscheck.c
@@ -90,6 +90,14 @@ main(int argc, // I - Number of command-line arguments
{
tls_options |= _HTTP_TLS_DENY_CBC;
}
+ else if (!strcmp(argv[i], "--no-ecc"))
+ {
+ tls_options |= _HTTP_TLS_DENY_ECC;
+ }
+ else if (!strcmp(argv[i], "--no-rsa"))
+ {
+ tls_options |= _HTTP_TLS_DENY_RSA;
+ }
else if (!strcmp(argv[i], "--no-tls10"))
{
tls_min_version = _HTTP_TLS_1_1;
@@ -250,6 +258,8 @@ usage(FILE *fp) // I - Output file
fputs(" --dh Allow DH/DHE key exchange\n", fp);
fputs(" --help Show help\n", fp);
fputs(" --no-cbc Disable CBC cipher suites\n", fp);
+ fputs(" --no-ecc Disable ECDSA/EdDSA certificates\n", fp);
+ fputs(" --no-rsa Disable RSA certificates\n", fp);
fputs(" --no-tls10 Disable TLS/1.0\n", fp);
fputs(" --rc4 Allow RC4 encryption\n", fp);
fputs(" --tls10 Only use TLS/1.0\n", fp);
diff --git a/cups/usersys.c b/cups/usersys.c
index d8f904364..4ea84700e 100644
--- a/cups/usersys.c
+++ b/cups/usersys.c
@@ -1113,7 +1113,7 @@ _cupsSetDefaults(void)
DEBUG_printf("1_cupsSetDefaults: DigestOptions %s", cg->digestoptions == _CUPS_DIGESTOPTIONS_DENYMD5 ? "DenyMD5" : "None");
DEBUG_printf("1_cupsSetDefaults: Encryption %s", encryptions[cg->encryption]);
DEBUG_printf("1_cupsSetDefaults: ServerName %s", cg->servername);
- DEBUG_printf("1_cupsSetDefaults: SSLOptions%s%s%s%s Min%s Max%s", cc.ssl_options == _HTTP_TLS_NONE ? " none" : "", (cc.ssl_options & _HTTP_TLS_ALLOW_RC4) ? " AllowRC4" : "", (cc.ssl_options & _HTTP_TLS_ALLOW_DH) ? " AllowDH" : "", (cc.ssl_options & _HTTP_TLS_DENY_CBC) ? " DenyCBC" : "", tls_versions[cc.ssl_min_version], tls_versions[cc.ssl_max_version]);
+ DEBUG_printf("1_cupsSetDefaults: SSLOptions%s%s%s%s%s%s Min%s Max%s", cc.ssl_options == _HTTP_TLS_NONE ? " none" : "", (cc.ssl_options & _HTTP_TLS_ALLOW_RC4) ? " AllowRC4" : "", (cc.ssl_options & _HTTP_TLS_ALLOW_DH) ? " AllowDH" : "", (cc.ssl_options & _HTTP_TLS_DENY_CBC) ? " DenyCBC" : "", (cc.ssl_options & _HTTP_TLS_DENY_ECC) ? " DenyECC" : "", (cc.ssl_options & _HTTP_TLS_DENY_RSA) ? " DenyRSA" : "", tls_versions[cc.ssl_min_version], tls_versions[cc.ssl_max_version]);
DEBUG_printf("1_cupsSetDefaults: TrustOnFirstUse %s", cg->trust_first ? "Yes" : "No");
DEBUG_printf("1_cupsSetDefaults: User %s", cg->user);
DEBUG_printf("1_cupsSetDefaults: UserAgentTokens %s", uatokens[cg->uatokens]);
@@ -1621,7 +1621,7 @@ cups_set_ssl_options(
_cups_client_conf_t *cc, // I - client.conf values
const char *value) // I - Value
{
- // SSLOptions [AllowRC4] [AllowSSL3] [AllowDH] [DenyTLS1.0] [None]
+ // SSLOptions [AllowRC4] [AllowSSL3] [AllowDH] [DenyCBC] [DenyECC] [DenyRSA] [DenyTLS1.0] [None]
int options = _HTTP_TLS_NONE, // TLS options
min_version = _HTTP_TLS_1_0, // Minimum TLS version
max_version = _HTTP_TLS_MAX; // Maximum TLS version
@@ -1651,6 +1651,10 @@ cups_set_ssl_options(
options |= _HTTP_TLS_ALLOW_DH;
else if (!_cups_strcasecmp(start, "DenyCBC"))
options |= _HTTP_TLS_DENY_CBC;
+ else if (!_cups_strcasecmp(start, "DenyECC"))
+ options |= _HTTP_TLS_DENY_ECC;
+ else if (!_cups_strcasecmp(start, "DenyRSA"))
+ options |= _HTTP_TLS_DENY_RSA;
else if (!_cups_strcasecmp(start, "DenyTLS1.0"))
min_version = _HTTP_TLS_1_1;
else if (!_cups_strcasecmp(start, "MaxTLS1.0"))
diff --git a/doc/client.conf.html b/doc/client.conf.html
index df86d3b88..9ef19f26e 100644
--- a/doc/client.conf.html
+++ b/doc/client.conf.html
@@ -209,7 +209,7 @@ Directives
Specifies the address and optionally the port to use when connecting to a server running CUPS 1.3.12 and earlier.
The default is the local spooler's domain socket.
- SSLOptions [AllowDH] [AllowRC4] [AllowSSL3] [DenyCBC] [DenyTLS1.0] [MaxTLS1.0] [MaxTLS1.1] [MaxTLS1.2] [MaxTLS1.3] [MinTLS1.0] [MinTLS1.1] [MinTLS1.2] [MinTLS1.3]
+
SSLOptions [AllowDH] [AllowRC4] [AllowSSL3] [DenyCBC] [DenyECC] [DenyRSA] [DenyTLS1.0] [MaxTLS1.0] [MaxTLS1.1] [MaxTLS1.2] [MaxTLS1.3] [MinTLS1.0] [MinTLS1.1] [MinTLS1.2] [MinTLS1.3]
SSLOptions None
Sets encryption options.
@@ -235,6 +235,14 @@
Directives
DenyCBC
option disables all CBC cipher suites.
The
+DenyECC
+option disables certificates and signatures using elliptic curve (ECDSA and EdDSA) keys.
+The
+DenyRSA
+option disables certificates and signatures using RSA keys.
+These options do not change the key exchange, which uses post-quantum hybrid (ML-KEM) groups when supported by the TLS library.
+If both options are used, only post-quantum (ML-DSA) certificates can be used and TLS v1.3 is required.
+The
DenyTLS1.0
option disables TLS v1.0 support - this sets the minimum protocol version to TLS v1.1.
The
diff --git a/man/client.conf.5 b/man/client.conf.5
index 4e0ee262a..8dbe5d3dd 100644
--- a/man/client.conf.5
+++ b/man/client.conf.5
@@ -124,7 +124,7 @@ Specifies the address and optionally the port to use when connecting to a server
The default is the local spooler's domain socket.
.\"#SSLOptions
.TP 5
-\fBSSLOptions \fR[\fBAllowDH\fR] [\fBAllowRC4\fR] [\fBAllowSSL3\fR] [\fBDenyCBC\fR] [\fBDenyTLS1.0\fR] [\fBMaxTLS1.0\fR] [\fBMaxTLS1.1\fR] [\fBMaxTLS1.2\fR] [\fBMaxTLS1.3\fR] [\fBMinTLS1.0\fR] [\fBMinTLS1.1\fR] [\fBMinTLS1.2\fR] [\fBMinTLS1.3]\fR
+\fBSSLOptions \fR[\fBAllowDH\fR] [\fBAllowRC4\fR] [\fBAllowSSL3\fR] [\fBDenyCBC\fR] [\fBDenyECC\fR] [\fBDenyRSA\fR] [\fBDenyTLS1.0\fR] [\fBMaxTLS1.0\fR] [\fBMaxTLS1.1\fR] [\fBMaxTLS1.2\fR] [\fBMaxTLS1.3\fR] [\fBMinTLS1.0\fR] [\fBMinTLS1.1\fR] [\fBMinTLS1.2\fR] [\fBMinTLS1.3]\fR
.TP 5
\fBSSLOptions None\fR
Sets encryption options.
@@ -150,6 +150,14 @@ The
.B DenyCBC
option disables all CBC cipher suites.
The
+.B DenyECC
+option disables certificates and signatures using elliptic curve (ECDSA and EdDSA) keys.
+The
+.B DenyRSA
+option disables certificates and signatures using RSA keys.
+These options do not change the key exchange, which uses post-quantum hybrid (ML-KEM) groups when supported by the TLS library.
+If both options are used, only post-quantum (ML-DSA) certificates can be used and TLS v1.3 is required.
+The
.B DenyTLS1.0
option disables TLS v1.0 support - this sets the minimum protocol version to TLS v1.1.
The