NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Software Development Kit (SDK) and API Discussions

Python - How to disable SSL certificate verification

pierrecarette
134,923 Views

To keep things simple I'd like to disable the certificate verification when connectiing via HTTPs:

 

s = NaServer("##.##.##.##", 1 , 31)
s.set_server_type("FILER")
s.set_transport_type("HTTPS")
s.set_port(443)
s.set_style("LOGIN")
print(s.is_server_cert_verification_enabled())
s.set_admin_user("admin", "####")

 

 s.is_server_cert_verification_enabled() is False by default

 

but I still get this error:

 

<results status="failed" reason="[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)" errno="13001"></results>

1 ACCEPTED SOLUTION

pierrecarette
134,915 Views

I found this solution, insert this code at the beginning of your source file:

 

import ssl

try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context

 

View solution in original post

4 REPLIES 4

pierrecarette
134,916 Views

I found this solution, insert this code at the beginning of your source file:

 

import ssl

try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context

 

RaviTeja1988
119,052 Views

Thank you. It's helps me a lot.

Ankoji
53,665 Views

I am  encountering the same error message with netapp-ontap 9.8 python client library. I tried to apply the specified fix for ssl verification error but no luck. Can someone please suggest a fix for this?

ken
NetApp
47,774 Views

For the newer python client library add verify=False to your HostConnection string:

 

config.CONNECTION = HostConnection('hostname or IP', 'user', 'password', verify=False)

 

Public