python-2.7mcafee

McAfee python script, SSL Failed to Verify


So for my job I have been required to learn Python for McAfee... Anyway I cannot find any decent documentation, so I thought I would add my notes here and see it anyone can improve on my solutions.

Anyway I have been getting the below error:

    Error/reason: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)>

My code is below, with private info removed

    import mcafee

    mc = mcafee.client("172.16.153.194", "8443","admin","password")

    #code specific to this task
    input = "mytag" #

    systems = mc.system.find(input)#Search text can be IP address, MAC address, user name, agent GUID or tag
    #The above uses the System Tree for searching
    for system in systems:
        #The below file contains EPOComputerProperties
        #the file is in the for loop to all each device to produce results 
    for each property
        file = open('C:/.../.../.../myquery.txt')
        for i in file:
            id = system[i.rstrip('\n')]
            print id
        print ""
        file.close()

Solution

  • So my solution was to use a Monkey patch (an ill advised Monkey patch...) using the below code at the top of my work:

        import ssl
    
        ssl._create_default_https_context = ssl._create_unverified_context
    

    If you can find a better way to achieve the connection, without providing a valid cert for my ePO server please let me know.