+\hdZddlmZddlmZddlmZddlmZddlm Z m Z m Z ddl m Z e rddlmZmZdd Zdd ZGd d Zy )z%Utilities for caching OCSP responses.) annotations) namedtuple)datetime)timezone) TYPE_CHECKINGAnyOptional) _create_lock) OCSPRequest OCSPResponsecJt|dr |jS|jS)z7Compat helper to return the response's next_update_utc.next_update_utc)hasattrr next_updatevalues U/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/ocsp_cache.py _next_updater'u'($$$   cJt|dr |jS|jS)z7Compat helper to return the response's this_update_utc.this_update_utc)rr this_updaters r _this_updater&rrcFeZdZdZedgdZd dZd dZd dZd dZ y) _OCSPCachezA cache for OCSP responses.OcspResponseCacheKeyhash_algorithmissuer_name_hashissuer_key_hash serial_numberc0i|_t|_y)N)_datar _lock)selfs r__init__z_OCSPCache.__init__6s.0 !^ rc|j|jjj|j|j |j S)Nr)CACHE_KEY_TYPErnamelowerr r!r")r& ocsp_requests r_get_cache_keyz_OCSPCache._get_cache_key;sM""'66;;AAC)::(88&44 #  rc^|j5|j|}t|}|&|jj |d dddyt |}| dddyt jtj}|j|jd}||cxkr|ks n dddy|jj|d}|||j|< dddyt|}|||kr||j|<dddy#1swYyxYw)zAdd/update a cache entry. 'key' is of type cryptography.x509.ocsp.OCSPRequest 'value' is of type cryptography.x509.ocsp.OCSPResponse Validity of the OCSP response must be checked by caller. Ntztzinfo) r%r-rr$popr _datetimenowrutcr2replaceget) r&keyr cache_keyrrr5 cached_valuecached_next_updates r __setitem__z_OCSPCache.__setitem__Cs*ZZ .++C0I 'u-K" y$/ . .'u-K" . .--8<<0C!!)kkk.344) . .0 ::>>)T:L#(- 9%7 . .8".l!; !-2D{2R(- 9%= . . .s$rNs;,""*//%@U&U&r