Forum Discussion
Uploading certificates : no exception but do not work (Python / SOAP API)
Hello all,
I am trying to upload some certs with the SOAP API and some python code and I don't quite understand the result.
My code seems good (to me at least 😉 ), there's no exception raised, but my certificate is not uploaded / installed...
Here's the code :
import getpass
import pycontrol.pycontrol as pc
import time
cert = """PEM
CERT
HERE"""
hosts = [('HERE GOES THE IP','THE PARTITION')]
uname = 'your user name'
upass = getpass.getpass("Password : ")
def upload_files(name, pem_cert):
For each host in hosts
for elem in hosts:
host = elem[0]
part = elem[1]
print host
b = pc.BIGIP(
hostname = host,
username = uname,
password = upass,
fromurl = True,
wsdls = ['Management.KeyCertificate','Management.Partition']
)
v = b.Management.KeyCertificate
p = b.Management.Partition
p.set_active_partition(part)
mode = v.typefactory.create("Management.KeyCertificate.ManagementModeType")
print len(v.get_certificate_list(mode.MANAGEMENT_MODE_DEFAULT))
Upload
v.certificate_import_from_pem(mode=mode.MANAGEMENT_MODE_DEFAULT, cert_ids=name, pem_data=pem_cert, overwrite=False)
time.sleep(3)
Verification
print len(v.get_certificate_list(mode.MANAGEMENT_MODE_DEFAULT))
upload_files("Name of the cert (after upload)", cert)
I searched through others topics but...
So thank you in advance for your help and answers !
Recently had some time to investigate again the problem and... Don't know if someone is actualy having the same but in case here is the answer :
v.certificate_import_from_pem(mode=mode.MANAGEMENT_MODE_DEFAULT, cert_ids=[name], pem_data=[pem_cert], overwrite=False)
No need for the time.sleep(3) by the way. So yeah, there was no errors, but the API was waiting for a list, dummy me that didn't look enough at the doc...
- dylang_327779Nimbostratus
Recently had some time to investigate again the problem and... Don't know if someone is actualy having the same but in case here is the answer :
v.certificate_import_from_pem(mode=mode.MANAGEMENT_MODE_DEFAULT, cert_ids=[name], pem_data=[pem_cert], overwrite=False)
No need for the time.sleep(3) by the way. So yeah, there was no errors, but the API was waiting for a list, dummy me that didn't look enough at the doc...
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com