#1154184 python3-gssapi: GSSAPI fails over TLS using ED25519 due to missing hash

Package:
python3-gssapi
Source:
python3-gssapi
Description:
Python 3 interface to GSSAPI
Submitter:
Dr. Lars Hanke
Date:
2026-11-16 18:39:02 UTC
Severity:
normal
Tags:
#1154184#5
Date:
2026-11-16 18:31:43 UTC
From:
To:
Dear Maintainer,

I only tested with ED25519, the rest is somehow suggestive musings of Gemini. I also didn't verify the claims about RFC5929 myself. The suggested fix looked plausible to me.

# Description
When connecting over TLS (`use_ssl=True` or `start_tls()`) and authenticating with SASL `KERBEROS` (or NTLM with channel bindings) against an LDAP server whose X.509 certificate is signed with **Ed25519** (or **Ed448**), `ldap3` crashes with:

```text
File ".../ldap3/protocol/sasl/kerberos.py", line 75, in get_channel_bindings
    hash_algorithm = cert.signature_hash_algorithm
    ...
AttributeError: 'NoneType' object has no attribute 'name'
```

# Root Cause
In `cryptography.x509.Certificate`, `cert.signature_hash_algorithm` returns `None` for signature algorithms that do not use a separate digest algorithm (such as Ed25519 and Ed448). Both `ldap3/protocol/sasl/kerberos.py` (`get_channel_bindings`) and `ldap3/core/connection.py` assume `cert.signature_hash_algorithm` is always an object with a `.name` attribute.

# Expected Behavior (RFC 5929)
Per RFC 5929 Section 4.1 (`tls-server-end-point`), when the certificate's signature algorithm has no associated hash function (or uses MD5/SHA-1), the channel binding certificate hash should fall back to **SHA-256** (or omit channel bindings when unsupported).

# Suggested Fix
In `ldap3/protocol/sasl/kerberos.py` (and the equivalent check in `ldap3/core/connection.py`):
```python
hash_algorithm = cert.signature_hash_algorithm
if hash_algorithm is None or hash_algorithm.name in ('md5', 'sha1'):
    digest_name = 'sha256'
else:
    digest_name = hash_algorithm.name
cert_hash = hashlib.new(digest_name, server_certificate).digest()
```