Reputation: 11
this is my code:
import requests
param = {
"username" : "login",
"password" : "password",
}
header = {
"content-type":"application/x-www-form-urlencoded"
}
r=requests.post("https://adres/rest/token", headers=header,params=param)
print(r.status_code)
And this is a result of this code:
Traceback (most recent call last):
File "C:\Users\holkam\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\holkam\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "C:\Users\holkam\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 849, in _validate_conn
conn.connect()
File "C:\Users\holkam\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connection.py", line 356, in connect
ssl_context=context)
File "C:\Users\holkam\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\ssl_.py", line 372, in ssl_wrap_socket
return context.wrap_socket(sock)
File "C:\Users\holkam\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 412, in wrap_socket
session=session
File "C:\Users\holkam\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 850, in _create
self.do_handshake()
File "C:\Users\holkam\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 1108, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)
I am trying to get a token from Security center using API and python3 according to documentation I need to issue a content type and credentials, but like above it is not working :(
Upvotes: 0
Views: 105
Reputation: 2201
It seems like API you're calling has self-signed certificate. Workaround you can use in this case:
r=requests.post("https://adres/rest/token", headers=header,params=param, verify=False)
verify=False
would not check SSL certificate for validity.
Upvotes: 0