# Renew letsencrypt certificate

**URL:** <https://forum.pritunl.com/t/renew-letsencrypt-certificate/615>\
**Category:** Pritunl VPN\
**Created:** [December 12, 2022, 2:32pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615 "2022-12-12T14:32:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![JTMosaic](https://forum.pritunl.com/user_avatar/forum.pritunl.com/jtmosaic/32/248_2.png) [@JTMosaic](https://forum.pritunl.com/u/JTMosaic)\
**Post date:** [December 12, 2022, 2:32pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/1 "2022-12-12T14:32:24Z")

</div>

We are using the build-in Let’s Encrypt functionality to set the SSL certificate for the pritunl web UI. However, for security we are closing port 80 to the server once the certificate is in place. We open it again a few days before the expiration of the current cert but we’ve not seen pritunl automatically update the certificate.

What is the best way to get the pritunl service to get a new lets encrypt certificate if I cannot get to the web UI?

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [December 12, 2022, 10:34pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/2 "2022-12-12T22:34:23Z")

</div>

The next release will include the command `sudo pritunl renew-ssl-cert` to manually renew Lets Encrypt certificates.

---

<div class="post-metadata">

**Author:** ![JTMosaic](https://forum.pritunl.com/user_avatar/forum.pritunl.com/jtmosaic/32/248_2.png) [@JTMosaic](https://forum.pritunl.com/u/JTMosaic)\
**Post date:** [December 12, 2022, 10:55pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/3 "2022-12-12T22:55:34Z")

</div>

Thanks!

Can you tell me why the current version isn’t automatically renewing it?

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [December 12, 2022, 11:03pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/4 "2022-12-12T23:03:15Z")

</div>

The server will automatically renew the certificate after 80 days. The top right logs will show any errors that occur on the renewal.

---

<div class="post-metadata">

**Author:** ![JTMosaic](https://forum.pritunl.com/user_avatar/forum.pritunl.com/jtmosaic/32/248_2.png) [@JTMosaic](https://forum.pritunl.com/u/JTMosaic)\
**Post date:** [December 13, 2022, 1:49pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/5 "2022-12-13T13:49:33Z")

</div>

What we’ve been doing is closing off port 80 after the renewal and opening it again a day or two before the certificate expires. Twice in a row, pritunl has failed to update the certificate.

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [December 14, 2022, 12:18am UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/6 "2022-12-14T00:18:23Z")

</div>

This can be avoided in the next release by using the command `sudo pritunl renew-ssl-cert` that will immediately trigger a certificate renewal.

---

<div class="post-metadata">

**Author:** ![JTMosaic](https://forum.pritunl.com/user_avatar/forum.pritunl.com/jtmosaic/32/248_2.png) [@JTMosaic](https://forum.pritunl.com/u/JTMosaic)\
**Post date:** [December 14, 2022, 1:46pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/7 "2022-12-14T13:46:13Z")

</div>

Thanks, but that doesn’t help us now.

---

<div class="post-metadata">

**Author:** ![ImDevinC](https://forum.pritunl.com/user_avatar/forum.pritunl.com/imdevinc/32/250_2.png) [@ImDevinC](https://forum.pritunl.com/u/ImDevinC)\
**Post date:** [December 14, 2022, 7:45pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/8 "2022-12-14T19:45:53Z")

</div>

We ran into this same issue and were able to fix it by doing the following:

1. Login to the web ui
2. Open settings
3. Change the “Lets Encrypt Domain” value to an incorrect domain
4. Save settings
5. Wait for an error to be returned. It should show up in the Web UI and tell you to check the logs.
6. Change the “Lets Encrypt Domain” value back to the correct domain
7. Save the settings
8. This should complete successfully

Hopefully the command to renew the cert comes out soon

---

<div class="post-metadata">

**Author:** ![JTMosaic](https://forum.pritunl.com/user_avatar/forum.pritunl.com/jtmosaic/32/248_2.png) [@JTMosaic](https://forum.pritunl.com/u/JTMosaic)\
**Post date:** [December 14, 2022, 7:59pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/9 "2022-12-14T19:59:32Z")

</div>

Thanks! We’ve already switched to a permanent certificate but this is helpful in case we decide to switch back at some point

---

<div class="post-metadata">

**Author:** ![Manu](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Manu](https://forum.pritunl.com/u/Manu)\
**Post date:** [January 23, 2024, 12:20pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/10 "2024-01-23T12:20:50Z")

</div>

@zach

pritunl server is not automatically renewing the certificate after 80 days, and its showing below error on logs. But can be manually renewed with the command mentioned above.

I need this thing to be automated, can you check on the logs below,

```auto
[vpn.prod.***.io][2023-11-30 14:08:56,878][ERROR] Failed to get LetsEncrypt cert
Traceback (most recent call last):
  File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/handlers/settings.py", line 905, in settings_put
    acme.update_acme_cert()
  File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/acme.py", line 67, in update_acme_cert
    csr = utils.generate_csr(private_key, settings.app.acme_domain)
  File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/utils/cert.py", line 72, in generate_csr
    with open(private_key_path, 'w') as private_key_file:
IOError: [Errno 2] No such file or directory: u'/tmp/pritunl_893fcc63e28441e9b1b2d62061efd9b5/c9d4d64eed124993bde76030aa8e2863.key'
  acme_domain = "vpn.prod. ******.io"
[vpn.prod. *****.io][2023-11-30 14:09:06,101][ERROR] Failed to get LetsEncrypt cert
Traceback (most recent call last):
  File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/handlers/settings.py", line 905, in settings_put
    acme.update_acme_cert()
  File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/acme.py", line 67, in update_acme_cert
    csr = utils.generate_csr(private_key, settings.app.acme_domain)
  File "/usr/lib/pritunl/lib/python2.7/site-packages/pritunl/utils/cert.py", line 72, in generate_csr
    with open(private_key_path, 'w') as private_key_file:
IOError: [Errno 2] No such file or directory: u'/tmp/pritunl_893fcc63e28441e9b1b2d62061efd9b5/9fa0d37ec2d6403a8379302bfd466cc4.key'
  acme_domain = "vpn.prod. *****.io"

```

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [January 23, 2024, 2:17pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/11 "2024-01-23T14:17:45Z")

</div>

That is likely an SELinux error. What Linux distribution is used and what repository is used in `/etc/yum.repos.d/pritunl.repo`?

---

<div class="post-metadata">

**Author:** ![Manu](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Manu](https://forum.pritunl.com/u/Manu)\
**Post date:** [January 23, 2024, 3:17pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/12 "2024-01-23T15:17:51Z")

</div>

@zach  
Repo used: `https://repo.pritunl.com/stable/yum/amazonlinux/2/`

Linux: **Amazon Linux 2** Also SELinux is disabled.

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [January 23, 2024, 3:35pm UTC](https://forum.pritunl.com/t/renew-letsencrypt-certificate/615/13 "2024-01-23T15:35:26Z")

</div>

It may have been an issue fixed in an update. The logs show a v1.29 Python 2 release, there have been a lot of updates since that release.
