<?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>topic Re: Tricks to work with self-signed certificate over TLS on python sdk 5.6 in Software Development Kit (SDK) and API Discussions</title>
    <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/129266#M2313</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using python 2.7.13 for connecting my 7-mode Filer using HTTPSConnection module like thisBut&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;connection = httplib.HTTPSConnection(server, port=443, timeout=300, context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am getting an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(&amp;lt;class 'ssl.SSLError'&amp;gt;, SSLError(1, u'[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:676)'), &amp;lt;traceback object at 0x7ff7bb69d128&amp;gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me what's wrong with it?&lt;/P&gt;&lt;P&gt;I can connect with the same code to Cluster-mode Filers but not 7-mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have already enabled tls, ssl3 options on this Filer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Mar 2017 05:11:19 GMT</pubDate>
    <dc:creator>Shivang</dc:creator>
    <dc:date>2017-03-22T05:11:19Z</dc:date>
    <item>
      <title>Tricks to work with self-signed certificate over TLS on python sdk 5.6</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/125198#M2148</link>
      <description>&lt;P&gt;Hi guys,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I am developing some automation using Python and it worked very well with HTTP protocol, but I needed to use &lt;STRONG&gt;HTTPS&lt;/STRONG&gt; instead. My scenario is:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; All my filers use TLS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; No SSL allowed due to SSL security issues&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; All my filers have self signed certificate&lt;BR /&gt;&lt;BR /&gt;I tried a lot of thing until I finally I decided to make some change on NetApp SDK library. On file &lt;STRONG&gt;NaServer.py&lt;/STRONG&gt; at line &lt;STRONG&gt;431&lt;/STRONG&gt; instead of:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;connection = httplib.HTTPSConnection(server, port=self.port, timeout=self.timeout)&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;I changed to&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;connection = httplib.HTTPSConnection(server, port=self.port, timeout=self.timeout, context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Now it works like a charm and I can run my program with HTTPS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Very important: this solution was tested using&amp;nbsp;Python 3.5.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 21:14:12 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/125198#M2148</guid>
      <dc:creator>FelipeMafra</dc:creator>
      <dc:date>2017-03-10T21:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Tricks to work with self-signed certificate over TLS on python sdk 5.6</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/128868#M2307</link>
      <description>&lt;P&gt;This works for python 2.7 as well.&lt;/P&gt;&lt;P&gt;In my scenario i have netapps using TLS or SSLv3, so i created a seperate NaServer.py which specified SSLv3 instead:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;connection = httplib.HTTPSConnection(server, port=self.port, timeout=self.timeout, context=ssl.SSLContext(ssl.PROTOCOL_SSLv3))&lt;/PRE&gt;&lt;P&gt;Then in my phython script i import both as such:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;from NaServer import *
import NaServer_SSL3&lt;/PRE&gt;&lt;P&gt;Then just have a simple boolean variable that i set to use the other library:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    def na_setup(netapp, sslv3=False):
        if sslv3:
            ss = NaServer_SSL3.NaServer(netapp, 1, 1)
        else:
            ss = NaServer(netapp, 1, 1)
    return ss&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried monkey patching ssl._create_default_https_context a few times, but as my script makes a tong of other api calls, this was a bit outside my python comfort zone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also worth mentioning that i battled weak ciphers with older 7mode systems for a few days and finally found a combination that worked for all my netapps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import ssl

try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    pass
else:
    ssl._create_default_https_context = _create_unverified_https_context

ssl._DEFAULT_CIPHERS += ':RC4-SHA'&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;You got me on the right path.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Matt S.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 19:03:35 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/128868#M2307</guid>
      <dc:creator>mjschneider</dc:creator>
      <dc:date>2017-03-09T19:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: Tricks to work with self-signed certificate over TLS on python sdk 5.6</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/129266#M2313</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using python 2.7.13 for connecting my 7-mode Filer using HTTPSConnection module like thisBut&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;connection = httplib.HTTPSConnection(server, port=443, timeout=300, context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am getting an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(&amp;lt;class 'ssl.SSLError'&amp;gt;, SSLError(1, u'[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:676)'), &amp;lt;traceback object at 0x7ff7bb69d128&amp;gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me what's wrong with it?&lt;/P&gt;&lt;P&gt;I can connect with the same code to Cluster-mode Filers but not 7-mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have already enabled tls, ssl3 options on this Filer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 05:11:19 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/129266#M2313</guid>
      <dc:creator>Shivang</dc:creator>
      <dc:date>2017-03-22T05:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Tricks to work with self-signed certificate over TLS on python sdk 5.6</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/129305#M2315</link>
      <description>&lt;P&gt;I would first try to generate a new certificate on one of the failing systems and make sure it's key length is the max (2048 i think). &amp;nbsp;The python standard libraries disabled handshake's with key lengths shorter than 1024 (i believe that theres a bug where it actually only works with 2048 key lengths) a few years ago; version i think was somewhere around 2.6.9 or so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may also need to add to the default cipher list as i mentioned in my post above. &amp;nbsp;I believe the order maters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;During my troubleshooting i has also installed the following packages, though i cant confirm if they contributed to my success:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;pip install requests[security] urllib3&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a fall back, i have a python 2.6.6 install that i use to verify its not something more than the cert. &amp;nbsp;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 16:54:21 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/129305#M2315</guid>
      <dc:creator>mjschneider</dc:creator>
      <dc:date>2017-03-22T16:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Tricks to work with self-signed certificate over TLS on python sdk 5.6</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/129944#M2324</link>
      <description>&lt;P&gt;Have you tried this..?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import ssl
ssl._create_default_https_context = ssl._create_unverified_context&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Apr 2017 08:27:46 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/129944#M2324</guid>
      <dc:creator>robinpeter</dc:creator>
      <dc:date>2017-04-09T08:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Tricks to work with self-signed certificate over TLS on python sdk 5.6</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/138513#M2593</link>
      <description>&lt;P&gt;Thanks. While adding that entry around line 433 in NaServer.py did the tricky for me.&lt;/P&gt;
&lt;P&gt;It seems like its skipping the certificate validation altogether. I have a signed certificate and cannot get it work on my 7mode system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason why I think its skipping cert validation is because I have wildcard based certificate and the connection goes through successfully irrespective of using fqdn or cname.&lt;/P&gt;
&lt;P&gt;On a cdot system though, it works like a charm ( without having to make any edits to NaServer.py). When I connect using fqdn instead of cname to a cdot system, it throws a error saying invalid matching name for the certificate ( This error goes away when line 433 is added which again proves the fact that cert validation is disabled when that line is added).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions is much appreciated,&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;-Prasad&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 21:21:35 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Tricks-to-work-with-self-signed-certificate-over-TLS-on-python-sdk-5-6/m-p/138513#M2593</guid>
      <dc:creator>prasadm</dc:creator>
      <dc:date>2018-02-28T21:21:35Z</dc:date>
    </item>
  </channel>
</rss>

