Guest User

Untitled

a guest
Feb 14th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. curl -k "https://192.168.2.1/api/login?username=admin&password=admin"
  2.  
  3. buffer = BytesIO()
  4. c = pycurl.Curl()
  5. c.setopt(c.URL, 'https://192.168.2.1/api/login?username=admin&password=admin')
  6. c.setopt(c.WRITEDATA, buffer)
  7. c.perform()
  8. c.close()
  9.  
  10. body = buffer.getvalue()
  11. # Body is a byte string.
  12. # We have to know the encoding in order to print it to a text file
  13. # such as standard output.
  14. print(body.decode("iso-8859-1"))
  15.  
  16. pycurl.error, (60, 'server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none')
  17.  
  18. urllib.error.URLError, <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)>
  19.  
  20. import urllib2
  21. f = urllib2.urlopen("https://ya.ru")
  22. print f.read()
  23.  
  24. import urllib.request
  25. f = urllib.request.urlopen('https://192.168.2.1/api/login?username=admin&password=admin')
  26. print (f.read())
  27.  
  28. import pycurl
  29.  
  30. c = pycurl.Curl()
  31. c.setopt(c.URL, 'https://ya.ru')
  32. c.perform()
  33.  
  34. $ openssl s_client -prexit -servername $host -connect $host:443 </dev/null | openssl x509 >server.crt
  35.  
  36. $ curl --cacert server.crt https://$host/path?query
  37.  
  38. import pycurl
  39.  
  40. c = pycurl.Curl()
  41. c.setopt(c.URL, url)
  42. c.setopt(c.CAINFO, 'server.crt')
  43. c.perform()
  44.  
  45. import requests
  46.  
  47. r = requests.get(url, verify='server.crt')
  48. print(r.text)
  49.  
  50. import ssl
  51. import urllib.request
  52.  
  53. context = ssl.create_default_context(cafile='server.crt')
  54. with urllib.request.urlopen(url, context=context) as r:
  55. print(r.read().decode(r.headers.get_content_charset('utf-8')))
  56.  
  57. c.setopt(c.SSL_VERIFYPEER, 0) # default 1
  58. c.setopt(c.SSL_VERIFYHOST, 0) # default 2
Add Comment
Please, Sign In to add comment