<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question SSL certification validation ignoring &amp;quot;-k&amp;quot; via python scripting in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/SSL-certification-validation-ignoring-quot-k-quot-via-python/m-p/79178#M82855</link>
    <description>&lt;P&gt;Dear Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to connect to cm api client with below python script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import sys&lt;BR /&gt;from datetime import datetime, timedelta&lt;BR /&gt;from cm_api.api_client import ApiResource&lt;BR /&gt;cm_host = "172.21.1.40"&lt;BR /&gt;cm_port = "7183"&lt;BR /&gt;cdh5 = None&lt;BR /&gt;cm_host = "&amp;lt;IP Address&amp;gt;"&lt;BR /&gt;api = ApiResource(cm_host, 7183, username=" ********", password="*********", use_tls=True)&lt;BR /&gt;for c in api.get_all_clusters():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print c.name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I get below error&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;...&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/api_client.py", line 131, in get_all_clusters&lt;BR /&gt;return clusters.get_all_clusters(self, view)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/endpoints/clusters.py", line 66, in get_all_clusters&lt;BR /&gt;params=view and dict(view=view) or None)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/endpoints/types.py", line 139, in call&lt;BR /&gt;ret = method(path, params=params)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/resource.py", line 110, in get&lt;BR /&gt;return self.invoke("GET", relpath, params)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/resource.py", line 73, in invoke&lt;BR /&gt;headers=headers)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/http_client.py", line 181, in execute&lt;BR /&gt;return self._opener.open(request)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 431, in open&lt;BR /&gt;response = self._open(req, data)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 449, in _open&lt;BR /&gt;'_open', req)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain&lt;BR /&gt;result = func(*args)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 1258, in https_open&lt;BR /&gt;context=self._context, check_hostname=self._check_hostname)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 1214, in do_open&lt;BR /&gt;raise URLError(err)&lt;BR /&gt;urllib2.URLError: &amp;lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)&amp;gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can overrided above error with below command manually&lt;STRONG&gt;[-k]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;curl -X post&amp;nbsp; &lt;STRONG&gt;-k -u&lt;/STRONG&gt; userid:**** &lt;A href="https://d1endevadh004.europe.easyjet.local:7183/api/v19/clusters/ADH-DEVELOPMENT001/commands/stop" target="_blank"&gt;https://******************:7183/api/v19/clusters/ADH-DEVELOPMENT001/commands/stop&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Now the problem statment is . I am not sure how to add -k option in python code basically don't know how to "Ignore SSL certification validation"&lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks and Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Naveen Srikanth D&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Aug 2018 14:39:26 GMT</pubDate>
    <dc:creator>GokuNaveen</dc:creator>
    <dc:date>2018-08-29T14:39:26Z</dc:date>
    <item>
      <title>SSL certification validation ignoring "-k" via python scripting</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/SSL-certification-validation-ignoring-quot-k-quot-via-python/m-p/79178#M82855</link>
      <description>&lt;P&gt;Dear Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to connect to cm api client with below python script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import sys&lt;BR /&gt;from datetime import datetime, timedelta&lt;BR /&gt;from cm_api.api_client import ApiResource&lt;BR /&gt;cm_host = "172.21.1.40"&lt;BR /&gt;cm_port = "7183"&lt;BR /&gt;cdh5 = None&lt;BR /&gt;cm_host = "&amp;lt;IP Address&amp;gt;"&lt;BR /&gt;api = ApiResource(cm_host, 7183, username=" ********", password="*********", use_tls=True)&lt;BR /&gt;for c in api.get_all_clusters():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print c.name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I get below error&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;...&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/api_client.py", line 131, in get_all_clusters&lt;BR /&gt;return clusters.get_all_clusters(self, view)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/endpoints/clusters.py", line 66, in get_all_clusters&lt;BR /&gt;params=view and dict(view=view) or None)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/endpoints/types.py", line 139, in call&lt;BR /&gt;ret = method(path, params=params)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/resource.py", line 110, in get&lt;BR /&gt;return self.invoke("GET", relpath, params)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/resource.py", line 73, in invoke&lt;BR /&gt;headers=headers)&lt;BR /&gt;File "/usr/lib/python2.7/site-packages/cm_api/http_client.py", line 181, in execute&lt;BR /&gt;return self._opener.open(request)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 431, in open&lt;BR /&gt;response = self._open(req, data)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 449, in _open&lt;BR /&gt;'_open', req)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain&lt;BR /&gt;result = func(*args)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 1258, in https_open&lt;BR /&gt;context=self._context, check_hostname=self._check_hostname)&lt;BR /&gt;File "/usr/lib64/python2.7/urllib2.py", line 1214, in do_open&lt;BR /&gt;raise URLError(err)&lt;BR /&gt;urllib2.URLError: &amp;lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)&amp;gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can overrided above error with below command manually&lt;STRONG&gt;[-k]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;curl -X post&amp;nbsp; &lt;STRONG&gt;-k -u&lt;/STRONG&gt; userid:**** &lt;A href="https://d1endevadh004.europe.easyjet.local:7183/api/v19/clusters/ADH-DEVELOPMENT001/commands/stop" target="_blank"&gt;https://******************:7183/api/v19/clusters/ADH-DEVELOPMENT001/commands/stop&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Now the problem statment is . I am not sure how to add -k option in python code basically don't know how to "Ignore SSL certification validation"&lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks and Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Naveen Srikanth D&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Aug 2018 14:39:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/SSL-certification-validation-ignoring-quot-k-quot-via-python/m-p/79178#M82855</guid>
      <dc:creator>GokuNaveen</dc:creator>
      <dc:date>2018-08-29T14:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: SSL certification validation ignoring "-k" via python scripting</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/SSL-certification-validation-ignoring-quot-k-quot-via-python/m-p/79229#M82856</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;you have to create an ssl_context before you open the connection and point it to the CA certificate:&lt;/P&gt;&lt;PRE&gt;import ssl

context = ssl.create_default_context(cafile=cmcertpath)
api = ApiResource( cm_host, '7183', username=username, password=password, use_tls=True, ssl_context=context)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 13:22:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/SSL-certification-validation-ignoring-quot-k-quot-via-python/m-p/79229#M82856</guid>
      <dc:creator>Tomas79</dc:creator>
      <dc:date>2018-08-30T13:22:48Z</dc:date>
    </item>
  </channel>
</rss>

