Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cfssl/cfssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ class CFSSL(object):
https://github.com/cloudflare/cfssl/tree/master/doc/api
"""

def __init__(self, host, port, ssl=True):
def __init__(self, host, port, ssl=True, verify_cert=True):
""" Initialize the CFSSL object.

Args:
host (str): Host or IP of remote CFSSL instance.
port (int): Port number of remote CFSSL instance.
ssl (bool): Whether to use SSL.
verify_cert (bool or str): File path of CA cert for verification,
`True` to use system certs, or `False` to disable certificate
verification.
"""
ssl = 'https' if ssl else 'http'
self.verify = verify_cert
self.uri_base = '%s://%s:%d' % (ssl, host, port)

def auth_sign(self, token, request, datetime=None, remote_address=None):
Expand Down Expand Up @@ -72,7 +83,7 @@ def bundle(self, certificate, private_key=None,
domain name.

Returns:
dict: Object repesenting the bundle, with the following keys:
dict: Object representing the bundle, with the following keys:
* bundle contains the concatenated list of PEM certificates
forming the certificate chain; this forms the actual
bundle. The remaining parameters are additional metadata
Expand Down Expand Up @@ -365,6 +376,7 @@ def call(self, endpoint, method='GET', params=None, data=None):
url=endpoint,
params=params,
data=data,
verify=self.verify,
)
response = response.json()
if not response['success']:
Expand Down
1 change: 1 addition & 0 deletions cfssl/tests/test_cfssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def test_call_request(self, requests):
url='https://test:1/api/v1/cfssl/endpoint',
params='params',
data='data',
verify=True,
)

@mock.patch.object(requests, 'request')
Expand Down