# Bug: Expired cert used after renewal

**URL:** <https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128>\
**Category:** Certificate\
**Created:** [19 November 2021 18:09 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128 "2021-11-19T18:09:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![clustertrump](https://yyz2.discourse-cdn.com/free1/user_avatar/syncloud.discourse.group/clustertrump/32/58_2.png) [@clustertrump](https://syncloud.discourse.group/u/clustertrump)\
**Post date:** [19 November 2021 18:09 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/1 "2021-11-19T18:09:21Z")

</div>

My Syncloud is currently using an expired TLS certificate stored at /var/snap/platform/current/syncloud.crt. Judging from the logs, when certbot is run automatically it fails because it hits LetsEncrypt’s [rate limit for renewals](https://letsencrypt.org/docs/rate-limits/). It seems to have successfully renewed on 2021-11-15 and 2021-11-11 judging from [these records](https://crt.sh/?id=5614194476). That renewed certificate (from the 15th) is present at /var/snap/platform/common/syncloud.crt. Because certbot is run with --force-renewal it does not respect the rate limit error.

I have already tried:

- restarting snap.platform.nginx-public
- refreshing the platform snap
- rebooting the device
- re-activating the device

Misc. info:  
System version: 2110221095  
Installer version: 210929152  
Output of `nmap -p 80,443 $mydomain.syncloud.it` is:

```auto
PORT STATE SERVICE
80/tcp open http
443/tcp open https

```

Is anybody else encountering this? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [19 November 2021 22:42 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/2 "2021-11-19T22:42:32Z")

</div>

There was a bug as I remember during the recent upgrades but it was fixed later.  
When did you upgrade to this version?

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [19 November 2021 22:59 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/3 "2021-11-19T22:59:50Z")

</div>

Also to check if you still have this bug you can run this command and should only print one log setting:

```auto
grep common -R /var/snap/platform/current/certbot/renewal

/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:logs_dir = /var/snap/platform/common/log

```

If it prints more that means we have not manage to fix it for all use cases.  
Of it pronts one line most likely you just need to eait for 10 days since the upgrade.

---

<div class="post-metadata">

**Author:** ![clustertrump](https://yyz2.discourse-cdn.com/free1/user_avatar/syncloud.discourse.group/clustertrump/32/58_2.png) [@clustertrump](https://syncloud.discourse.group/u/clustertrump)\
**Post date:** [19 November 2021 23:16 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/4 "2021-11-19T23:16:34Z")

</div>

I upgraded from 2109251054 on the 11th.

That search finds:

```auto
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:archive_dir = /var/snap/platform/common/certbot/archive/[domain].syncloud.it
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:cert = /var/snap/platform/common/certbot/live/[domain].syncloud.it/cert.pem
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:privkey = /var/snap/platform/common/certbot/live/[domain].syncloud.it/privkey.pem
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:chain = /var/snap/platform/common/certbot/live/[domain].syncloud.it/chain.pem
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:fullchain = /var/snap/platform/common/certbot/live/[domain].syncloud.it/fullchain.pem
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:logs_dir = /var/snap/platform/common/log

```

I don’t see an issue that matches, is it related to [this](https://github.com/syncloud/platform/commit/b5e875a1cb1cbb655df04119ec4791a76f846811) change?

---

<div class="post-metadata">

**Author:** ![Christoph](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@Christoph](https://syncloud.discourse.group/u/Christoph)\
**Post date:** [20 November 2021 09:14 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/5 "2021-11-20T09:14:50Z")

</div>

I have the same problem.  
System version: 2110221095  
Installer version: 210929152

Have you already found a solution? I can no longer access Nextcloud. But I need it every day for my work.

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [20 November 2021 09:49 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/6 "2021-11-20T09:49:54Z")

</div>

@clustertrump the output above is showing that migration did not go right. Can you run this and post the output?

```auto
/snap/platform/current/bin/migrate_certbot_to_current.sh

```

Then again:

```auto
grep common -R /var/snap/platform/current/certbot/renewal

```

---

<div class="post-metadata">

**Author:** ![Christoph](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@Christoph](https://syncloud.discourse.group/u/Christoph)\
**Post date:** [20 November 2021 16:51 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/7 "2021-11-20T16:51:41Z")

</div>

root@syncloud:~# grep common -R /var/snap/platform/current/certbot/renewal  
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:archive\_dir = /var/snap/platfor/common/certbot/archive/[domain].syncloud.it  
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:cert = /var/snap/platform/commo/certbot/live/[domain].syncloud.it/cert.pem  
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:privkey = /var/snap/platform/commo/certbot/live/[domain].syncloud.it/privkey.pem  
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:chain = /var/snap/platform/commo/certbot/live/[domain].syncloud.it/chain.pem  
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:fullchain = /var/snap/platform/commo/certbot/live/[domain].syncloud.it/fullchain.pem  
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:logs\_dir = /var/snap/platform/common/log  
root@syncloud:~#

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [20 November 2021 17:27 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/8 "2021-11-20T17:27:31Z")

</div>

What is the output of the migration script?

---

<div class="post-metadata">

**Author:** ![clustertrump](https://yyz2.discourse-cdn.com/free1/user_avatar/syncloud.discourse.group/clustertrump/32/58_2.png) [@clustertrump](https://syncloud.discourse.group/u/clustertrump)\
**Post date:** [20 November 2021 17:42 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/9 "2021-11-20T17:42:22Z")

</div>

```auto
root@syncloud:~# sh /snap/platform/current/bin/migrate_certbot_to_current.sh 
/snap/platform/current/bin/migrate_certbot_to_current.sh: 7: /snap/platform/current/bin/migrate_certbot_to_current.sh: [[: not found
/snap/platform/current/bin/migrate_certbot_to_current.sh: 16: /snap/platform/current/bin/migrate_certbot_to_current.sh: [[: not found

```

grep’s output is unchanged.

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [20 November 2021 18:04 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/10 "2021-11-20T18:04:13Z")

</div>

Could you run it without sh?

---

<div class="post-metadata">

**Author:** ![clustertrump](https://yyz2.discourse-cdn.com/free1/user_avatar/syncloud.discourse.group/clustertrump/32/58_2.png) [@clustertrump](https://syncloud.discourse.group/u/clustertrump)\
**Post date:** [20 November 2021 18:17 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/11 "2021-11-20T18:17:44Z")

</div>

```auto
root@syncloud:~# /snap/platform/current/bin/migrate_certbot_to_current.sh 
root@syncloud:~# echo $?
0

```

```auto

root@syncloud:~# grep common -R /var/snap/platform/current/certbot/renewal
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:archive_dir = /var/snap/platform/common/certbot/archive/[domain].syncloud.it
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:cert = /var/snap/platform/common/certbot/live/[domain].syncloud.it/cert.pem
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:privkey = /var/snap/platform/common/certbot/live/[domain].syncloud.it/privkey.pem
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:chain = /var/snap/platform/common/certbot/live/[domain].syncloud.it/chain.pem
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:fullchain = /var/snap/platform/common/certbot/live/[domain].syncloud.it/fullchain.pem
/var/snap/platform/current/certbot/renewal/[domain].syncloud.it.conf:logs_dir = /var/snap/platform/common/log

```

Also if helpful:

```auto
root@syncloud:~# bash -x /snap/platform/current/bin/migrate_certbot_to_current.sh 
+ bash -x /snap/platform/current/bin/migrate_certbot_to_current.sh
+ OLD_CERTBOT=/var/snap/platform/common/certbot
+ NEW_CERTBOT=/var/snap/platform/current/certbot
+ [[-d /var/snap/platform/common/certbot]]
+ [[-d /var/snap/platform/current/certbot]]
++ ls -la /var/snap/platform/current/certbot/live
++ wc -l
+ certs=5
+ [[5 -gt 5]]
+ [[! -d /var/snap/platform/current/certbot]]
root@syncloud:~# echo $?
+ echo 0
0

```

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [21 November 2021 08:11 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/12 "2021-11-21T08:11:50Z")

</div>

Ok, can you remove new (not working) certbot config:

```auto
rm -rf /var/snap/platform/current/certbot

```

And run migration again:

```auto
/snap/platform/current/bin/migrate_certbot_to_current.sh 

```

---

<div class="post-metadata">

**Author:** ![clustertrump](https://yyz2.discourse-cdn.com/free1/user_avatar/syncloud.discourse.group/clustertrump/32/58_2.png) [@clustertrump](https://syncloud.discourse.group/u/clustertrump)\
**Post date:** [21 November 2021 17:29 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/13 "2021-11-21T17:29:40Z")

</div>

After doing that and restarting nginx the correct cert is being used. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [21 November 2021 18:56 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/14 "2021-11-21T18:56:36Z")

</div>

Sorry for that seems like migration did not go wrong for some users in past.

---

<div class="post-metadata">

**Author:** ![raphm](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@raphm](https://syncloud.discourse.group/u/raphm)\
**Post date:** [22 November 2021 13:00 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/15 "2021-11-22T13:00:48Z")

</div>

Hi @boris, can you confirm that if the output of the following command shows only 1 line (as in your example) then the only thing to do is **wait**?

> [@boris](#):
>
> `grep common -R /var/snap/platform/current/certbot/renewal`

I’m just wondering if I’m waiting for nothing and if there is something else to check or not.  
Thanks !

---

<div class="post-metadata">

**Author:** ![pirboazo](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@pirboazo](https://syncloud.discourse.group/u/pirboazo)\
**Post date:** [22 November 2021 17:33 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/16 "2021-11-22T17:33:22Z")

</div>

Hi Boris,  
I apply your solution, describe above.  
It’s work fine.

Thank you.  
Pierre

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [22 November 2021 18:05 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/17 "2021-11-22T18:05:59Z")

</div>

Check your `/var/snap/platform/common/log/letsencrypt.log` and see what is the reason?  
Is it rate limit or something else?  
Do not paste the log here as it will reveal your domain name.

---

<div class="post-metadata">

**Author:** ![raphm](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@raphm](https://syncloud.discourse.group/u/raphm)\
**Post date:** [23 November 2021 08:04 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/18 "2021-11-23T08:04:53Z")

</div>

Thanks ! It was indeed a rate limit error.  
It’s all good now.

---

<div class="post-metadata">

**Author:** ![peter](https://yyz2.discourse-cdn.com/free1/user_avatar/syncloud.discourse.group/peter/32/57_2.png) [@peter](https://syncloud.discourse.group/u/peter)\
**Post date:** [25 January 2022 15:38 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/19 "2022-01-25T15:38:25Z")

</div>

I can’t find the migrate\_certbot… script ☹ But the output of

```auto
grep common -R /var/snap/platform/current/certbot/renewal

```

is only one line

---

<div class="post-metadata">

**Author:** ![boris](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@boris](https://syncloud.discourse.group/u/boris)\
**Post date:** [25 January 2022 18:13 UTC](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128/20 "2022-01-25T18:13:21Z")

</div>

What type of domain do you have free/premium/custom?  
What system version are you on (Settings - Updates)?

[Next page](https://syncloud.discourse.group/t/bug-expired-cert-used-after-renewal/128.md?page=2)
