Forum Discussion

Preyansh_247983's avatar
Preyansh_247983
Historic F5 Account
May 12, 2017

Getting SSL certificate error for using iREST API get method in python

I am getting this error while trying to use Rest API get method on BIGIP in python:
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.htmlsnimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.htmlinsecureplatformwarning.
  InsecurePlatformWarning
Traceback (most recent call last):
  File "api_sig.py", line 9, in 
    r =  requests.get(url,headers=header,timeout=5)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 447, 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 am new to using API in python. following is the code i am using. Can someone please help me out?

 

!/usr/bin/python
import requests
import json

url = 'https://10.192.69.17/mgmt/tm/security/dos/dos-signature'
header = {'Accept': 'application/json', 'Host': '10.192.69.17', 'Authorization': 'Basic YWRtaW46YWRtaW4='}
certificate = 'default'
r =  requests.get(url,headers=header,cert=certificate,timeout=5)
response = r.text
print response

7 Replies