# Uploading certificates : no exception but do not work (Python / SOAP API)

**URL:** <https://community.f5.com/t/uploading-certificates-no-exception-but-do-not-work-python-soap-api/25063>\
**Category:** Technical Forums\
**Tags:** icontrol, big-ip, devops\
**Created:** [October 3, 2017, 2:51pm UTC](https://community.f5.com/t/uploading-certificates-no-exception-but-do-not-work-python-soap-api/25063 "2017-10-03T14:51:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dylang\_327779](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@dylang\_327779](https://community.f5.com/u/dylang_327779)\
**Post date:** [October 3, 2017, 2:51pm UTC](https://community.f5.com/t/uploading-certificates-no-exception-but-do-not-work-python-soap-api/25063/1 "2017-10-03T14:51:54Z")

</div>

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 :

```tcl
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 !

---

<div class="post-metadata">

**Author:** ![dylang\_327779](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@dylang\_327779](https://community.f5.com/u/dylang_327779)\
**Post date:** [November 10, 2017, 12:02pm UTC](https://community.f5.com/t/uploading-certificates-no-exception-but-do-not-work-python-soap-api/25063/2 "2017-11-10T12:02:00Z")

</div>

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 :

```tcl
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…
