Brian_Gibson_30
Sep 10, 2013Nimbostratus
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.