Forum Discussion

Brian_Gibson_30's avatar
Brian_Gibson_30
Icon for Nimbostratus rankNimbostratus
Sep 10, 2013

Trying to check cert validity - Bigsuds Python

I am trying to retrieve the validity of the certs stored in my LTM. Here is the relevant code. targetltm creates the connection to the LTM.

 

def get_cert_list(obj):
    try:
        certlist = obj.Management.KeyCertificate.get_certificate_list("MANAGEMENT_MODE_DEFAULT")
        certname = []
        for a in (certlist):
            certname.append(a["certificate"]["cert_info"]["id"])
        return certname
    except Exception, e:
        print e
try:
            host = targetltm(target)
            localcert = get_cert_list(host)
            validity = host.Management.KeyCertificate.certificate_check_validity("MANAGEMENT_MODE_DEFAULT", localcert, 8000)

When it gets to the last line I get "'int' object is not iterable". However localcert is iterable and when I print it I get a list of cert IDs. Clearly I'm not doing something right but I'm at a loss as to what.

 

Note: I'm fairly new to Python so there may be some obvious style issues as well with the code.

 

3 Replies

  • OK. I figured out my problem. I didn't realize that the watermarks were iterable as well. Seems kinda silly to me but that's the way the API is set up.

     

    • arjunnambiartc_'s avatar
      arjunnambiartc_
      Icon for Nimbostratus rankNimbostratus
      just to understand..what is the use of the watermark attribute while checking the cert validity ?