Git Product home page Git Product logo

certbot-namecheap-hook's Introduction

Certbot Namecheap Hook

If Namecheap is your DNS registrar, the scripts can be used to automatically obtain/renew wildcard certificates using Certbot.

Introduction

Every certificate applied from Certbot expires in three months. It's frustrating that you have to renew certs every three months. Though Certbot supports auto renewing them by setting up a Cron task. However, it doesn't support auto renewing wildcard certificates due to the limitation ofdns-01 challenge. This repository uses Namecheap API updating your DNS record to fight back the Certbot challenge.

Get Started

Pre-requirements

  • Ensure you have your Namecheap account API key at hand. Refer to get API key.

  • Python 3 is required to get the script working

Run Scripts

The main.sh is a sample script showing how to use Certbot to obtain/renew a wildcard cert. Please refer to it and create your own customized scripts.

When you trial-and-error your customized script, you are highly recommended to hit the staging environment instead of production environment. Let's Encrypt has strict rate limit, which can be easily run out (then you have to wait another week to get your production certs).

Required Environment Variables

There are several environment variables required to get the namecheap.py working.

Env Variable Comment Example
API_USER Normally, it's the same with your username username
API_KEY Namecheap account API key your-api-key
USERNAME Namecheap account username username
CLIENT_IP The public IP which you use to hit the API 10.42.193.39
SLD Second level domain haomingyin
TLD Top level domain com

To use the sample main.sh script, you have set up the following environment variables as well.

Env Variable Comment Example
APPLY_DOMAIN The domain you are applying cert for. Wildcard is allowed *.haomingyin.com or Certbot.haomingyin.com
EMAIL The email to register a let's encrypt account [email protected]
ACME_MODE Staging mode or production mode staging or prod

How Do I Use It

I have my Jenkins server periodically run the script. The reason I'm not using Cron is that I have several severs and can't be bothered to set it up on each server. Also, by using Jenkins Pipeline, the latest scripts will always be sync and updated among all my servers. You welcome to check out my Jenkins Pipeline file.

Reference

certbot-namecheap-hook's People

Contributors

haomingyin avatar

Stargazers

Richard Eriksson avatar  avatar Jonas Müller avatar

Watchers

 avatar

certbot-namecheap-hook's Issues

Fixing bugs when attempting to renew a certificate which requires multiple TXT records

So, in reviewing this script and logic there is a bug here wherein if you attempt to renew a certificate that aliases both the wildcard and the second-level domain in the same cert, the validation fails.

eg. (example.com + *.example.com)

The problem is that two TXT records are necessary here to validate both domains (and possibly even more if you keep attempting to traverse)

As you are already running a cleanup of the old records in ./cleanup.sh, there is no need for the line 128 in namecheap.py removing the existing _acme-challenge TXT record in the set_challenge_record method. You should be appending any new records you need and allowing the cleanup script to remove any records which should not be tehre

Fixing relative path issue in main.sh

When attempting to execute this main.sh, it's important to be in the root of the script for the associated scripts to work correctly

I would recommend prepending this line to the main.sh file to automatically cd into the correct directory to prevent any odd bugs

SUB_DIR="$(dirname $0)"
if [[ "$PWD" != "$SUB_DIR" ]]; then
  cd "$SUB_DIR"
fi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.