I need help in verifying SSL certificate within the company's firewall when trying to access the cloud hosted application https://www.quickbase.com/. The pyquickbase module works perfectly when I run the script from home. Here is my code and traceback for your reference.
### Python script to log into database
import quickbase
client = quickbase.Client(username='JohnDoe',password='OpenQB', database='qb_database',
apptoken='xxxdfdafd', base_url="https://www.quickbase.com")
response = client.list_db_pages(database='qb_database')
print(response)
###
Traceback (most recent call last):
File "D:\Users\User123\Documents\pyfund\Quickbase\QB_api_check.py", line 3, in <module>
apptoken='xxxdfdafd', base_url="https://www.quickbase.com")
File "C:\Python27\lib\site-packages\quickbase.py", line 191, in __init__
self.authenticate()
File "C:\Python27\lib\site-packages\quickbase.py", line 263, in authenticate
required=['ticket', 'userid'], ticket=False)
File "C:\Python27\lib\site-packages\quickbase.py", line 219, in request
request = requests.post(url, data, headers=headers)
File "C:\Python27\lib\site-packages\requests\api.py", line 111, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 57, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 585, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 477, in send
raise SSLError(e, request=request)
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
Ok, I tried setting up the proxy with OS environment variable and that did not work since the requests.get required that I pass the proxy within the call. I created a proxy Dict as
proxyDict = {
"http" : http_proxy,
"https" : https_proxy,
"ftp" : ftp_proxy
}
The https one was the one that was required in order to receive SSL certificate. I will now have to modify the quickbase and pybase modules that I am using to explicitly include the proxies in the calls.
Related
In Python Requests module, using proxy connection to browse some url
I added proxy ip and port to https_proxy and http_proxy environment variables to route the traffic to proxy
import os
import requests
os.environ["HTTPS_PROXY"] = "proxy1.xx.local:8081"
os.environ["HTTP_PROXY"] = "proxy1xx.local:8081"
H = {"X-Authenticated-User": "bharani#dummy.com"}
url = r"https://google.co.in"
r = requests.get(url,headers=H,verify=False)
print r.status_code
print r.text
Response I'm getting from above code
Traceback (most recent call last):
File "pilot.py", line 356, in <module>
r = requests.get(url,headers=H,verify=False)
File "C:\Python27\lib\site-packages\requests\api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)
pyopenssl, ndg-httpsclient, pyasn1 are also installed.
Not sure What I'm missing.
I am trying to send web request to my php code via linux running on raspberry pi. I am using putty to access the OS. When I am running the code, I am getting gai error-2. Below is my code:
import requests
values = {'"firstname":' "abc ", '"lastname":' "xyz"}
r = requests.post('http://rts.msmq.site/security.php', data=values)
I am unable to figure out the problem. Can someone let me know what could be the issue? I am using linux.
Error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 94, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 407, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
gaierror stands for get_address_info_error, which means urllib is having trouble reaching the hostname 'http://rts.msmq.site/security.php', check that you can nslookup rts.msmq.site or dig rts.msmq.site and ping rts.msmq.site
I am trying to get a response using python requests. However I'm facing SSL Handshake error. I tried many solutions posted here, but nothing seems to work. Please help. Thanks in advance
This is the code:
import requests
url = "https://androidappsapk.co/download/com.facebook.katana"
requests.get(url, verify = False)
This is the error that I am getting :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 456, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 382, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)
P.S. - I am using Python 2.7.11
I updated OpenSSL to the latest version and it's working fine now :)
I am trying to pull PayPal order information using Python and paypalrestsdk.
For some reason I am getting an certificate error that does not make sense to me.
payment_history = paypalrestsdk.Payment.all({"count": 10}, api=PayPal_key.Key_api())
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/resource.py", line 137, in all
response = api.get(url)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 222, in get
return self.request(util.join_url(self.endpoint, action), 'GET', headers=headers or {})
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 135, in request
http_headers = util.merge_dict(self.headers(refresh_token=refresh_token), headers or {})
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 205, in headers
token_hash = self.get_token_hash(refresh_token=refresh_token)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 98, in get_token_hash
"Accept": "application/json", "User-Agent": self.user_agent
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/paypalrestsdk-1.6.2-py2.7.egg/paypalrestsdk/api.py", line 161, in http_call
response = requests.request(method, url, proxies=self.proxies, **kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-2.5.0-py2.7.egg/requests/api.py", line 49, in request
response = session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-2.5.0-py2.7.egg/requests/sessions.py", line 461, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-2.5.0-py2.7.egg/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/requests-2.5.0-py2.7.egg/requests/adapters.py", line 431, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
I checked the paypal.com certificate:
requests.get('https://paypal.com', verify=True)
and got:
<Response [200]>
Could someone help to resolve this?
The certificate presented by paypal.com is different from that presented by their API endpoints, so your test:
requests.get('https://paypal.com', verify=True)
.. does not reveal the issue you're having when trying to use their APIs.
If you are still having issues, I recommend taking a look at upgrading the underlying version of OpenSSL to ensure you're using a version that supports TLS 1.2 which PayPal's API endpoints require.
I need to call a web requests and Im using Python request module.
I have a requests being served on a machine For ex:55.84.201.228. When I enter it throught the browser it works fine and Im able to view the webpage..
but when I use the requests.get, it does not work..It errors with a socket error..
>>> import requests
>>> r = requests.get('https://55.84.201.228')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 378, in send
raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='55.84.201.228', port=443): Max retries exceeded with url: / (Caused by <class 'socket.error'>: [Errno 110] Connection timed out)
How can I fix this issue?
>>>r = requests.get('https://www.cnn.com')
This works fine.
I am making a wild guess here since I can't access your machine but from experience, since you are using https on what I assume is some test server try
r = requests.get('https://55.84.201.228', verify=False)
According to the documentation certificate verification is on by default.