# Adding Certificate Does Not Create SNI

**URL:** <https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497>\
**Category:** Questions\
**Created:** [December 20, 2018, 8:07pm UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497 "2018-12-20T20:07:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darrell\_Henderson](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@Darrell\_Henderson](https://discuss.konghq.com/u/Darrell_Henderson)\
**Post date:** [December 20, 2018, 8:07pm UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/1 "2018-12-20T20:07:21Z")

</div>

I am attempting to add a SSL certificate to Kong 1.0 and I am not getting this to work as expected. I add the certificate with:

```
curl -i -m 60 -X POST http://localhost:8001/certificates -F "cert=$(cat cert.pem)" -F "key=$(cat key.pem)" -F "snis=domain.net"

```

Then I get this response:

```
{
    "created_at": 1422386534,
    "cert": "-----BEGIN CERTIFICATE-----...",
    "key": "-----BEGIN RSA PRIVATE KEY-----..."
    "snis": []
}

```

I do not seem to be getting the certificate id or creating the SNI. Am I doing something wrong here?

---

<div class="post-metadata">

**Author:** ![Raimon\_Grau](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/raimon_grau/32/854_2.png) [@Raimon\_Grau](https://discuss.konghq.com/u/Raimon_Grau)\
**Post date:** [December 20, 2018, 8:36pm UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/2 "2018-12-20T20:36:08Z")

</div>

Hello @Darrell_Henderson,

It looks like you’re passing the snis field as a string and not as an array. Alternatively, you can add the sni for a given certificate separately in its own [/snis endpoint](https://docs.konghq.com/1.0.x/admin-api/#add-sni)

---

<div class="post-metadata">

**Author:** ![Darrell\_Henderson](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@Darrell\_Henderson](https://discuss.konghq.com/u/Darrell_Henderson)\
**Post date:** [December 20, 2018, 8:43pm UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/3 "2018-12-20T20:43:44Z")

</div>

Thanks, @Raimon_Grau,

I have tried passing in multiple SNI’s separated by commas, and I get the same response. I also can not use the /snis endpoint because I am not given a certificate id. Attempting to find the certificate id with GET /certificates gives me similar data.

---

<div class="post-metadata">

**Author:** ![Raimon\_Grau](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/raimon_grau/32/854_2.png) [@Raimon\_Grau](https://discuss.konghq.com/u/Raimon_Grau)\
**Post date:** [December 20, 2018, 9:20pm UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/4 "2018-12-20T21:20:46Z")

</div>

Could you try with this format for passing arrays: `-F "snis[]=domain.net"`. This should send the parameter formated as an array.

Still, very strange that you’re not getting the “id” back (can’t reproduce that behavior in 1.0.0).

---

<div class="post-metadata">

**Author:** ![Darrell\_Henderson](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@Darrell\_Henderson](https://discuss.konghq.com/u/Darrell_Henderson)\
**Post date:** [December 20, 2018, 9:26pm UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/5 "2018-12-20T21:26:50Z")

</div>

Ahh that did it. Using the array format it added the SNI and when I look at the GET /snis there is a certificate ID. However no cigar. My connection still has the self signed certificate.

It might also be helpful to mention that I am using docker 1.0.0rc3-alpine.

---

<div class="post-metadata">

**Author:** ![Raimon\_Grau](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/raimon_grau/32/854_2.png) [@Raimon\_Grau](https://discuss.konghq.com/u/Raimon_Grau)\
**Post date:** [December 20, 2018, 9:40pm UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/6 "2018-12-20T21:40:27Z")

</div>

Kong 1.0.0 was just released today, would you try with that, to confirm it’s not working with the latest available Kong?

---

<div class="post-metadata">

**Author:** ![Darrell\_Henderson](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@Darrell\_Henderson](https://discuss.konghq.com/u/Darrell_Henderson)\
**Post date:** [December 21, 2018, 2:07pm UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/7 "2018-12-21T14:07:59Z")

</div>

I have a work around going right now. I will update when I have a proper solution in place.

---

<div class="post-metadata">

**Author:** ![AB2019](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AB2019](https://discuss.konghq.com/u/AB2019)\
**Post date:** [October 28, 2019, 10:33am UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/8 "2019-10-28T10:33:32Z")

</div>

Having the same problem on Kong CE 1.3.0:

Adding a new certificate with -F “snis=example.tld, example2.tld,example3.tld” (as found in the docs) does not add the snis object, it stays empty.

Adding a certificate with -F “snis[]=example.tld” -F “snis[]=example2.tld” -F “snis[]=example3.tld” does only save the last array entry (“example3.tld”) as a snis object.

So how do I correctly add a new certificate with several entries in a snis object? (using urlencoded (–data) does not work while I use files as input for cert and key)

---

<div class="post-metadata">

**Author:** ![AB2019](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@AB2019](https://discuss.konghq.com/u/AB2019)\
**Post date:** [October 28, 2019, 11:22am UTC](https://discuss.konghq.com/t/adding-certificate-does-not-create-sni/2497/9 "2019-10-28T11:22:31Z")

</div>

Ok, I finally found a solution that is working:

```
curl -X POST -F "cert=@/path/to/cert.pem" -F "key=@/path/to/key.pem" -F "snis[0]=example.tld" -F "snis[1]=example2.tld" -F "snis[2]=example3.tld"

```

So it seems as if I have to explicitly state the array index. At least this works (for anyone coming by here with the same probs).
