What to do if you get an error when running "certbot renew" in CakePHP environment

About the environment

Error renewing SSL certificate

I'm using Let's Encrypt on a website. Let's Encrypt must be renewed every 3 months, and the certificate can be renewed from 1 month in advance.

It is quite troublesome to do it manually every time, so I decided to batch process with cron and automatically update SSL, and when it is executed, the result is returned by e-mail.

You will receive an update failure email

At one point, the subject of the update failure was in the email ...

Faild renew letsencript SSL cert

Currently the website is fine, but after the update period,

** Untrusted site **

Will be displayed, so we will deal with it immediately.

Into CentOS

I will try to execute it manually for the time being.

certbot renew --dry-run

The following results ...

Cahllenge failed for domain *****.jp
Challenge failed for domain www.*****.jp
Attempting to renew cert (www.*****.jp) from /etc/letsencrypt/renewal/www.*****.jp produced an unexpected error: Some challenges have failed.. Skipping.
All renewal attempts failed. The following certs could not be renewed:

Anyway, like this, it is written in a row about things that failed.

Notable is further below.

Domain: ******.jp
Type:   unauthorized
Detail: Invalid response from
https://******.jp/.well-known/acme-challenge/xZtOg19utX8Mch7n3hgYJNeNk4GM2PBw6LVqFgzs9pI
[153.***.***.***]: "<!DOCTYPE html>\n<html lang=\"ja\"
ng-app=\"NetCommonsApp\">\n<head>\n\t<meta
charset=\"utf-8\">\n\t<meta http-equiv=\"X-UA-Compatible\" conte"

** It didn't work when I accessed here ~ ** It says something like that.

https://******.jp/.well-known/acme-challenge/xZtOg19utX8Mch7n3hgYJNeNk4GM2PBw6LVqFgzs9pI

↑ Your domain + URL like ".well-known / acme-challenge".

It seems that the SSL certificate is placed here, but it failed because it can not be accessed.

I will guide you to the URL correctly

This time, we are building a website with apache + CakePHP2. The root directory looks like this: The apache side is also set to refer to the following path.

/var/www/html/cakephp

Once to the root directory

cd /var/www/html/cakephp

Since it is the root directory, it is normal to access here, CakePHP also redirects from here.

The file doing it

.htaccess

Will be.

The contents are like this.

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

I'm redirecting further to ** app / webroot ** in CakePHP.

However, since there is no well-known directory in webroot, If the URL "https://*****.jp/well-known" is accessed, do not redirect it.

Add the following statement

RewriteRule ^\.well-known(.*)$ .well-known$1 [L]

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^\.well-known(.*)$ .well-known$1 [L]
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

Now when you access well-known you will not be redirected!

Run again!

Execute the following command

certbot renew --dry-run

I forgot to keep a log of success. ..

The word ** failed ** does not appear, The word ** succeeded ** appears,

I think it's okay if you can confirm.

If successful, remove "--dry-run" and re-execute.

certbot renew 

The certificate has been successfully renewed.

the end.

Recommended Posts

What to do if you get an error when running "certbot renew" in CakePHP environment
What to do if you get an error when trying to load mnist
What to do if you get an error when installing Dlib (Ubuntu)
What to do if you get an error when installing python with pyenv
What to do if you get an OpenSSL error when installing Python 2 with pyenv
What to do if you get an Import Error when importing matplotlib with Jupyter
What to do if you get an error when trying to send a message in tasks.loop () immediately after startup
What to do if you get an Undefined error when trying to use pip with pyenv
An app that you must put in Linux
What to do if you get an error when importing matplotlib in Python (Mac)
When you get an error in python scraping (requests)
What to do if you get an error when running "certbot renew" in CakePHP environment
What to do if you get an error saying c compiler cannot create executables in configure
What to do if you get a must override `get_config` error when trying to model.save in Keras
What to do if you get a "No versions found" error in pipenv
What to do if you get "coverage unknown" in Coveralls
What to do if you get an "unknown service" error from your gRPC server
What to do if you get a memory error when converting from PySparkDataFrame to PandasDataFrame
What to do if you get "(35,'SSL connect error')" in pycurl (one of them)
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
What to do if you run python in IntelliJ and end with an error
What to do if you get a minus zero in Python
What to do when you get an error saying "Name resolution temporarily failed" on linux
What to do if you get a Cannot retrieve metalink for repository error in yum
What to do if you can't find PDO in Laravel or CakePHP
What to do if you get lost in file reference with FileNotFoundError
What to do if you get angry in TensorFlow v2 without attribute'app'
What to do if an error occurs when importing numpy with VScode
What to do if you can't install with pip in babun environment
[OSX] [pyenv] What to do when an SSL error occurs in pip
What to do when psycopg2 throws an error when pipenv lock under Pipenv environment
What to do if pip --user returns an error in a virtual environment created with pyenv
What to do if you get an error when vagrant up when you enable public_network or private_network on Vagrant + Arch Linux → Install netctl
[Python] What to do if an error occurs in pip (pyinstaller, pyautogui, etc.)
Workaround if you get an error when trying to install PySide with pip
What to do if you get an error like'Qstring' has already been set to version 1 using mne python
[python] What to do when an error occurs in send_keys of headless chrome
What to do when SSL error occurs in pip in Windows10, miniconda, VScode environment
What to do if you get angry with "Value Error: unknown local: UTF-8" in python manage.py syncdb
What to do if you get a Permission denied (public key) error when trying to pull on Github
What to do if you get "Python not configured." Using PyDev in Eclipse
[Python] What to check when you get a Unicode Decode Error in Django
[Python] What to do if you get a ModuleNotFoundError when importing pandas using Jupyter Notebook in Anaconda
When you get an error in python scraping (requests)
What to do if you are told "Import Error: cannot import name'HTTPSHandler'" when building a virtual environment using virtualenv
What to do if you get `No kernel for language python found` in Hydrogen
What to do if the print command itself causes an error in Maya python
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()
What to do when an error occurs with import _ssl
What to do if you can't log in as root
What to do if you get a Call with too many input arguments error at DoAndReturn in a golang test
What to do if you get the error "Error: opencv3: Does not support building both Python 2 and 3 wrappers" when installing openCV 3
What to do if you get an Undefined error:'Module_six_moves_urllib_parse' object has no attribute'urlencode' on MacOS
[Beanstalk] What to do when an error occurs with import uuid
What to do if you get a UnicodeDecodeError with pip install
What to do if Insecure Platform Warning appears when running Python
What to do if you can't use the trash in Lubuntu 18.04.
What to do when you get "I can't see the site !!!!"
What to do if you get angry with'vertices' must be a 2D list ... in matplotlib arrow
What to do if you get angry if you don't have libxml / xmlversion.h when installing lxml on CentOS
What to do if you get an error like dyld: mach-o, but built for simulator or dyld: attempt to run simulator program outside simulator (DYLD_ROOT_PATH not set) in golang
What to do if you couldn't send an email to Yahoo with Python.
What to do if you can't use scikit grid search in Python
What to do if you get `locale.Error: unsupported locale setting` when getting the day of the week from a date in Python