Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SSL certificate verification optional #476

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion speeches/importers/import_akomantoso.py
Expand Up @@ -18,7 +18,7 @@ class ImportAkomaNtoso(ImporterBase):

def import_document(self, document_path):
if document_path.startswith('http'):
self.xml = objectify.fromstring(requests.get(document_path).content)
self.xml = objectify.fromstring(requests.get(document_path, verify=self.verify).content)
else:
self.xml = objectify.parse(document_path).getroot()
self.ns = self.xml.nsmap.get(None, None)
Expand Down
5 changes: 3 additions & 2 deletions speeches/importers/import_base.py
Expand Up @@ -3,11 +3,12 @@
logger = logging.getLogger(__name__)


class ImporterBase (object):
def __init__(self, instance=None, commit=True, clobber=None, **kwargs):
class ImporterBase(object):
def __init__(self, instance=None, commit=True, clobber=None, verify=True, **kwargs):
self.instance = instance
self.commit = commit
self.clobber = clobber
self.verify = verify
self.speakers = {}

self.stats = {}
Expand Down
3 changes: 3 additions & 0 deletions speeches/management/import_commands.py
Expand Up @@ -24,6 +24,9 @@ class ImportCommand(BaseCommand):
make_option('--instance', action='store', help='Label of instance to add data to'),
make_option('--file', action='store', help='document to import'),
make_option('--dir', action='store', help='directory of documents to import'),
make_option(
'--no-verify', action='store_false', default=True, dest='verify',
help='Whether to verify SSL certificates or not'),
make_option(
'--start-date', action='store', default='',
help='earliest date to process, in yyyy-mm-dd format'),
Expand Down
2 changes: 1 addition & 1 deletion speeches/tests/importer_tests.py
Expand Up @@ -11,7 +11,7 @@


class FakeRequestsOutput(object):
def __init__(self, source):
def __init__(self, source, verify=True):
assert source.startswith('http://example.com/')

# We'll put things that would have been served from a url ending
Expand Down