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

Add option for custom cert #135

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions SPARQLWrapper/Wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class SPARQLWrapper(object):
pattern = re.compile(r"(?P<queryType>(CONSTRUCT|SELECT|ASK|DESCRIBE|INSERT|DELETE|CREATE|CLEAR|DROP|LOAD|COPY|MOVE|ADD))", re.VERBOSE | re.IGNORECASE)
comments_pattern = re.compile(r"(^|\n)\s*#.*?\n")

def __init__(self, endpoint, updateEndpoint=None, returnFormat=XML, defaultGraph=None, agent=__agent__):
def __init__(self, endpoint, updateEndpoint=None, returnFormat=XML, defaultGraph=None, agent=__agent__, cafile=None):
"""
Class encapsulating a full SPARQL call.
@param endpoint: string of the SPARQL endpoint's URI
Expand Down Expand Up @@ -399,6 +399,7 @@ def __init__(self, endpoint, updateEndpoint=None, returnFormat=XML, defaultGraph
self._defaultGraph = defaultGraph
self.onlyConneg = False # Only Content Negotiation
self.customHttpHeaders = {}
self.cafile = cafile

if returnFormat in _allowedFormats:
self._defaultReturnFormat = returnFormat
Expand Down Expand Up @@ -888,9 +889,9 @@ def _query(self):

try:
if self.timeout:
response = urlopener(request, timeout=self.timeout)
response = urlopener(request, timeout=self.timeout, cafile=self.cafile)
else:
response = urlopener(request)
response = urlopener(request, cafile=self.cafile)
return response, self.returnFormat
except urllib2.HTTPError, e:
if e.code == 400:
Expand Down