File tree Expand file tree Collapse file tree 4 files changed +11
-1
lines changed
Expand file tree Collapse file tree 4 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 3535KEYLOADERR = "Failed to load %s key from '%s' (%s)"
3636REMOTE_FAILED = "Remote key update from '{}' failed, HTTP status {}"
3737MALFORMED = "Remote key update from {} failed, malformed JWKS."
38+ DEFAULT_HTTPC_TIMEOUT = 10
3839
3940LOGGER = logging .getLogger (__name__ )
4041
@@ -254,6 +255,8 @@ def __init__(
254255 self .httpc = requests .request
255256
256257 self .httpc_params = httpc_params or {}
258+ if not self .httpc_params .get ("timeout" ):
259+ self .httpc_params ["timeout" ] = DEFAULT_HTTPC_TIMEOUT
257260
258261 if keys :
259262 self .source = None
Original file line number Diff line number Diff line change 1212from .key_bundle import build_key_bundle
1313from .key_bundle import key_diff
1414from .key_bundle import update_key_bundle
15+ from .key_bundle import DEFAULT_HTTPC_TIMEOUT
1516from .utils import importer
1617from .utils import qualified_name
1718
@@ -58,6 +59,8 @@ def __init__(
5859 self .ca_certs = ca_certs
5960 self .httpc = httpc or request
6061 self .httpc_params = httpc_params or {}
62+ if not self .httpc_params .get ("timeout" ):
63+ self .httpc_params ["timeout" ] = DEFAULT_HTTPC_TIMEOUT
6164 self .keybundle_cls = keybundle_cls
6265 self .name = name
6366 self .remove_after = remove_after
Original file line number Diff line number Diff line change 99from .jwe .jwe import alg2keytype as jwe_alg2keytype
1010from .jws .utils import alg2keytype as jws_alg2keytype
1111from .key_bundle import KeyBundle
12+ from .key_bundle import DEFAULT_HTTPC_TIMEOUT
1213from .key_issuer import KeyIssuer
1314from .key_issuer import build_keyissuer
1415from .key_issuer import init_key_issuer
@@ -51,6 +52,9 @@ def __init__(
5152 self .remove_after = remove_after
5253 self .httpc = httpc or request
5354 self .httpc_params = httpc_params or {}
55+ if not self .httpc_params .get ("timeout" ):
56+ self .httpc_params ["timeout" ] = DEFAULT_HTTPC_TIMEOUT
57+
5458 # Now part of httpc_params
5559 # self.verify_ssl = verify_ssl
5660 if not self .httpc_params : # backward compatibility
Original file line number Diff line number Diff line change @@ -774,7 +774,7 @@ def test_localhost_url():
774774
775775 kb = issuer .find (url )
776776 assert len (kb ) == 1
777- assert kb [0 ].httpc_params == {"verify" : False }
777+ assert kb [0 ].httpc_params == {"timeout" : 10 , " verify" : False }
778778
779779
780780def test_add_url ():
You can’t perform that action at this time.
0 commit comments