Skip to content

Commit bbb3782

Browse files
committed
Fix Requester verify typing to allow setting CA path
1 parent db31eaa commit bbb3782

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=True, cert=
3838
# For HTTPS Nomad instances with cert file and key
3939
n = nomad.Nomad(host="https://172.16.100.10", secure=True, timeout=5, verify=True, cert=("/path/to/certfile", "/path/to/key")) # See http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification
4040

41+
# For HTTPS Nomad instance with cert file and key and CA file
42+
n = nomad.Nomad(host="https://172.16.100.10", secure=True, timeout=5, verify="/path/to/cacert", cert=("/path/to/certfile", "/path/to/key"))
43+
4144
# For HTTPS Nomad instances with namespace and acl token
4245
n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=False, namespace='Namespace-example',token='3f4a0fcd-7c42-773c-25db-2d31ba0c05fe')
4346

nomad/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Nomad Python library"""
22

33
import os
4-
from typing import Optional
4+
from typing import Optional, Union
55

66
import requests
77

@@ -25,7 +25,7 @@ def __init__( # pylint: disable=too-many-arguments
2525
timeout: int = 5,
2626
region: Optional[str] = None,
2727
version: str = "v1",
28-
verify: bool = False,
28+
verify: Union[bool, str] = False,
2929
cert: tuple = (),
3030
session: requests.Session = None,
3131
):
@@ -39,8 +39,8 @@ def __init__( # pylint: disable=too-many-arguments
3939
- user_agent (defaults None), custom user agent for requests to Nomad.
4040
- secure (defaults False), define if the protocol is secured or not (https or http)
4141
- version (defaults v1), version of the api of nomad.
42-
- verify (defaults False), verify the certificate when tls/ssl is enabled
43-
at nomad.
42+
- verify (defaults False), verify SSL certificates for HTTPS requests. Can be a boolean to enable/disable
43+
verification, or a string path to a CA certificate file.
4444
- cert (defaults empty), cert, or key and cert file to validate the certificate
4545
configured at nomad.
4646
- region (defaults None), version of the region to use. It will be used then

nomad/api/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Requester"""
22

3-
from typing import Optional
3+
from typing import Optional, Union
44

55
import requests
66

@@ -24,7 +24,7 @@ def __init__( # pylint: disable=too-many-arguments
2424
token: Optional[str] = None,
2525
timeout: int = 5,
2626
version: str = "v1",
27-
verify: bool = False,
27+
verify: Union[bool, str] = False,
2828
cert: tuple = (),
2929
region: Optional[str] = None,
3030
session: requests.Session = None,

0 commit comments

Comments
 (0)