@@ -378,8 +378,11 @@ def __init__(
378
378
* rest_api_version -- the version of the REST resources under rest_path to use. Defaults to ``2``.
379
379
* agile_rest_path - the REST path to use for Jira Agile requests. Defaults to ``greenhopper`` (old, private
380
380
API). Check :py:class:`jira.resources.GreenHopperResource` for other supported values.
381
- * verify -- Verify SSL certs. Defaults to ``True``.
382
- * client_cert -- a tuple of (cert,key) for the requests library for client side SSL
381
+ * verify (Union[bool, str]) -- Verify SSL certs. Defaults to ``True``.
382
+ Or path to to a CA_BUNDLE file or directory with certificates of trusted CAs,
383
+ for the `requests` library to use.
384
+ * client_cert (Union[str, Tuple[str,str]]) -- Path to file with both cert and key or
385
+ a tuple of (cert,key), for the `requests` library to use for client side SSL.
383
386
* check_update -- Check whether using the newest python-jira library version.
384
387
* headers -- a dict to update the default headers the session uses for all API requests.
385
388
@@ -480,7 +483,6 @@ def __init__(
480
483
self ._create_oauth_session (oauth , timeout )
481
484
elif basic_auth :
482
485
self ._create_http_basic_session (* basic_auth , timeout = timeout )
483
- self ._session .headers .update (self ._options ["headers" ])
484
486
elif jwt :
485
487
self ._create_jwt_session (jwt , timeout )
486
488
elif token_auth :
@@ -492,12 +494,12 @@ def __init__(
492
494
# always log in for cookie based auth, as we need a first request to be logged in
493
495
validate = True
494
496
else :
495
- verify = bool (self ._options ["verify" ])
496
497
self ._session = ResilientSession (timeout = timeout )
497
- self ._session .verify = verify
498
498
499
499
# Add the client authentication certificate to the request if configured
500
500
self ._add_client_cert_to_session ()
501
+ # Add the SSL Cert to the request if configured
502
+ self ._add_ssl_cert_verif_strategy_to_session ()
501
503
502
504
self ._session .headers .update (self ._options ["headers" ])
503
505
@@ -571,7 +573,6 @@ def _create_cookie_auth(
571
573
):
572
574
self ._session = ResilientSession (timeout = timeout )
573
575
self ._session .auth = JiraCookieAuth (self ._session , self .session , auth )
574
- self ._session .verify = bool (self ._options ["verify" ])
575
576
576
577
def _check_update_ (self ):
577
578
"""Check if the current version of the library is outdated."""
@@ -3356,15 +3357,12 @@ def _create_http_basic_session(
3356
3357
Returns:
3357
3358
ResilientSession
3358
3359
"""
3359
- verify = bool (self ._options ["verify" ])
3360
3360
self ._session = ResilientSession (timeout = timeout )
3361
- self ._session .verify = verify
3362
3361
self ._session .auth = (username , password )
3363
3362
3364
3363
def _create_oauth_session (
3365
3364
self , oauth , timeout : Optional [Union [Union [float , int ], Tuple [float , float ]]]
3366
3365
):
3367
- verify = bool (self ._options ["verify" ])
3368
3366
3369
3367
from oauthlib .oauth1 import SIGNATURE_RSA
3370
3368
from requests_oauthlib import OAuth1
@@ -3377,15 +3375,13 @@ def _create_oauth_session(
3377
3375
resource_owner_secret = oauth ["access_token_secret" ],
3378
3376
)
3379
3377
self ._session = ResilientSession (timeout )
3380
- self ._session .verify = verify
3381
3378
self ._session .auth = oauth_instance
3382
3379
3383
3380
def _create_kerberos_session (
3384
3381
self ,
3385
3382
timeout : Optional [Union [Union [float , int ], Tuple [float , float ]]],
3386
3383
kerberos_options = None ,
3387
3384
):
3388
- verify = bool (self ._options ["verify" ])
3389
3385
if kerberos_options is None :
3390
3386
kerberos_options = {}
3391
3387
@@ -3402,18 +3398,32 @@ def _create_kerberos_session(
3402
3398
)
3403
3399
3404
3400
self ._session = ResilientSession (timeout = timeout )
3405
- self ._session .verify = verify
3406
3401
self ._session .auth = HTTPKerberosAuth (
3407
3402
mutual_authentication = mutual_authentication
3408
3403
)
3409
3404
3410
3405
def _add_client_cert_to_session (self ):
3406
+ """Adds the client certificate to the session.
3407
+ If configured through the constructor.
3408
+
3409
+ https://docs.python-requests.org/en/master/user/advanced/#client-side-certificates
3410
+ - str: a single file (containing the private key and the certificate)
3411
+ - Tuple[str,str] a tuple of both files’ paths
3411
3412
"""
3412
- Adds the client certificate to the request if configured through the constructor.
3413
- """
3414
- client_cert : Tuple [str , str ] = self ._options ["client_cert" ] # to help mypy
3413
+ client_cert : Union [str , Tuple [str , str ]] = self ._options ["client_cert" ]
3415
3414
self ._session .cert = client_cert
3416
3415
3416
+ def _add_ssl_cert_verif_strategy_to_session (self ):
3417
+ """Adds verification strategy for host SSL certificates.
3418
+ If configured through the constructor.
3419
+
3420
+ https://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification
3421
+ - str: Path to a `CA_BUNDLE` file or directory with certificates of trusted CAs.
3422
+ - bool: True/False
3423
+ """
3424
+ ssl_cert : Union [bool , str ] = self ._options ["verify" ]
3425
+ self ._session .verify = ssl_cert
3426
+
3417
3427
@staticmethod
3418
3428
def _timestamp (dt : datetime .timedelta = None ):
3419
3429
t = datetime .datetime .utcnow ()
@@ -3439,7 +3449,6 @@ def _create_jwt_session(
3439
3449
for f in jwt ["payload" ].items ():
3440
3450
jwt_auth .add_field (f [0 ], f [1 ])
3441
3451
self ._session = ResilientSession (timeout = timeout )
3442
- self ._session .verify = bool (self ._options ["verify" ])
3443
3452
self ._session .auth = jwt_auth
3444
3453
3445
3454
def _create_token_session (
@@ -3451,9 +3460,7 @@ def _create_token_session(
3451
3460
Creates token-based session.
3452
3461
Header structure: "authorization": "Bearer <token_auth>"
3453
3462
"""
3454
- verify = self ._options ["verify" ]
3455
3463
self ._session = ResilientSession (timeout = timeout )
3456
- self ._session .verify = verify
3457
3464
self ._session .auth = TokenAuth (token_auth )
3458
3465
3459
3466
def _set_avatar (self , params , url , avatar ):
0 commit comments