Suppress InsecureRequestWarning: Unverified HTTPS request is being made in Python2.6

前端 未结 9 1081
南方客
南方客 2020-11-27 09:06

I am writing scripts in Python2.6 with use of pyVmomi and while using one of the connection methods:

service_instance = connect.SmartConnect(host=args.ip,
           


        
9条回答
  •  日久生厌
    2020-11-27 09:48

    Why not using pyvmomi original function SmartConnectNoSSL. They added this function on June 14, 2016 and named it ConnectNoSSL, one day after they changed the name to SmartConnectNoSSL, use that instead of by passing the warning with unnecessary lines of code in your project?

    Provides a standard method for connecting to a specified server without SSL verification. Useful when connecting to servers with self-signed certificates or when you wish to ignore SSL altogether

    service_instance = connect.SmartConnectNoSSL(host=args.ip,
                                                 user=args.user,
                                                 pwd=args.password)
    

提交回复
热议问题