Bug 55719 - python-pysaml2: wrong timeformat
Summary: python-pysaml2: wrong timeformat
Status: NEW
Alias: None
Product: UCS
Classification: Unclassified
Component: SAML
Version: UCS 5.0
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: UCS maintainers
QA Contact: UCS maintainers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-16 14:20 CET by Tim Breidenbach
Modified: 2025-10-07 10:29 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.091
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2024041921000267, 2025072321000162
Bug group (optional): Workaround is available
Customer ID: 02149
Max CVSS v3 score:


Attachments
saml2-validate.patch (1.13 KB, patch)
2025-07-30 15:06 CEST, Mirac Erdemiroglu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Breidenbach univentionstaff 2023-02-16 14:20:55 CET
A customer with external keycloak as identity provider saw tracebacks like this when trying to login:

"  File "/usr/lib/python3/dist-packages/saml2/validate.py", line 110, in validate_before
    "<= notbefore=%s" % (now_str, slack, not_before))
saml2.validate.ToEarly: Can&#x27;t use response yet: (now=2023-40-10T11:40:01Z + slack=0) <= notbefore=2023-02-10T11:40:02.147Z"

Rootcause was a typo in the python-pysaml2:

https://github.com/IdentityPython/pysaml2/commit/4f0a45c361bbd46b1f56f468d4712c0ef9797c1b

As no user was able to login the pain was (very) high.
Comment 1 Mika Westphal univentionstaff 2024-05-21 15:45:45 CEST
Version: 5.0-7 errata1024

Error:
Traceback (most recent call last):
  File "%PY3%/tornado/web.py", line 1595, in _execute
    result = yield result
  File "%PY3%/tornado/gen.py", line 1133, in run
    value = future.result()
  File "%PY3%/univention/management/console/saml.py", line 229, in get
    await acs(binding, message, relay_state)
  File "%PY3%/univention/management/console/saml.py", line 234, in attribute_consuming_service
    response = self.parse_authn_response(message, binding)
  File "%PY3%/univention/management/console/saml.py", line 321, in parse_authn_response
    response = self.sp.parse_authn_request_response(message, binding, self.outstanding_queries)
  File "%PY3%/saml2/client_base.py", line 702, in parse_authn_request_response
    binding, **kwargs)
  File "%PY3%/saml2/entity.py", line 1170, in _parse_response
    response = response.verify(keys)
  File "%PY3%/saml2/response.py", line 1018, in verify
    if self.parse_assertion(keys):
  File "%PY3%/saml2/response.py", line 930, in parse_assertion
    if not self._assertion(assertion, False):
  File "%PY3%/saml2/response.py", line 803, in _assertion
    if not self.condition_ok():
  File "%PY3%/saml2/response.py", line 593, in condition_ok
    validate_before(conditions.not_before, self.timeslack)
  File "%PY3%/saml2/validate.py", line 110, in validate_before
    "<= notbefore=%s" % (now_str, slack, not_before))
saml2.validate.ToEarly: Can't use response yet: (now=2024-40-19T18:40:23Z + slack=0) <= notbefore=2024-04-19T18:40:37Z

 Role: domaincontroller_slave
Comment 2 Mirac Erdemiroglu univentionstaff 2025-07-30 15:06:27 CEST
Created attachment 11331 [details]
saml2-validate.patch
Comment 3 Mirac Erdemiroglu univentionstaff 2025-10-07 10:27:23 CEST
Wrong date settings on the server could be the cause for this issue. So, the session created by Keycloak was in the future, but the server’s date settings were behind.

root@ucs5primary:~# date
Di 7. Okt 06:29:42 CEST 2025

Set the correct date/time for the server, could fix this issue.
root@ucs5primary:~# rdate -n 10.200.30.1
Tue Oct  7 10:08:08 CEST 2025
Comment 4 Mirac Erdemiroglu univentionstaff 2025-10-07 10:29:00 CEST
Changed user pain, because knowledge base article is available:

https://help.univention.com/t/problem-saml-login-fails-saml2-validate-toearly/24394