Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cups/http-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 29 additions & 2 deletions cups/tls-gnutls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
48 changes: 47 additions & 1 deletion cups/tls-openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
38 changes: 38 additions & 0 deletions cups/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
//
Expand Down
10 changes: 10 additions & 0 deletions cups/tlscheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions cups/usersys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"))
Expand Down
10 changes: 9 additions & 1 deletion doc/client.conf.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ <h3 id="client.conf-5.description.directives">Directives</h3>
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.
</p>
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>SSLOptions </strong>[<strong>AllowDH</strong>] [<strong>AllowRC4</strong>] [<strong>AllowSSL3</strong>] [<strong>DenyCBC</strong>] [<strong>DenyTLS1.0</strong>] [<strong>MaxTLS1.0</strong>] [<strong>MaxTLS1.1</strong>] [<strong>MaxTLS1.2</strong>] [<strong>MaxTLS1.3</strong>] [<strong>MinTLS1.0</strong>] [<strong>MinTLS1.1</strong>] [<strong>MinTLS1.2</strong>] [<strong>MinTLS1.3]</strong><br>
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>SSLOptions </strong>[<strong>AllowDH</strong>] [<strong>AllowRC4</strong>] [<strong>AllowSSL3</strong>] [<strong>DenyCBC</strong>] [<strong>DenyECC</strong>] [<strong>DenyRSA</strong>] [<strong>DenyTLS1.0</strong>] [<strong>MaxTLS1.0</strong>] [<strong>MaxTLS1.1</strong>] [<strong>MaxTLS1.2</strong>] [<strong>MaxTLS1.3</strong>] [<strong>MinTLS1.0</strong>] [<strong>MinTLS1.1</strong>] [<strong>MinTLS1.2</strong>] [<strong>MinTLS1.3]</strong><br>
</p>
<p style="margin-left: 2.5em; text-indent: -2.5em;"><strong>SSLOptions None</strong><br>
Sets encryption options.
Expand All @@ -235,6 +235,14 @@ <h3 id="client.conf-5.description.directives">Directives</h3>
<strong>DenyCBC</strong>
option disables all CBC cipher suites.
The
<strong>DenyECC</strong>
option disables certificates and signatures using elliptic curve (ECDSA and EdDSA) keys.
The
<strong>DenyRSA</strong>
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
<strong>DenyTLS1.0</strong>
option disables TLS v1.0 support - this sets the minimum protocol version to TLS v1.1.
The
Expand Down
10 changes: 9 additions & 1 deletion man/client.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down