Giter Club home page Giter Club logo

aws-letsencrypt-updater's Introduction

Let's Encrypt Updater

This is a project for me to explore the AWS CDK and patterns to manage SSL certificates from Let's Encrypt. You should not take anything in this repository as best practice. This is purely a tool for self directed leaning.

I run a lot of devices and services that have self-signed SSL certificates. Since these certificates are not trusted by by browser, I have to tell my system to trust the certificate or ignore invalid certificates.

You should not trust 3rd party self-signed certificates since you do not know the security practices that were used to generate the certificate. That certificate could be reused on all devices or services from a manufacturer. This opens an opportunity for someone with malicious intent.

Ignoring invalid certificates is not widely supported, and it usually has to be added for each request or session. This can get annoying and leads to trusting the certificate.

I could use AWS Certificate Manager (ACM). To use ACM with the on-premisis services and devices, you have to use a private certificate authority (CA) and export the certificates. To use this transparently, I would have to configure every host or application to trust the private CA. Unfortunately some applications don't support custom CAs.

To avoid these problems, I like to use Let's Encrypt's free SSL certificates. The certificates can be installed anywhere you need them and they are compatible with my choice of platforms.

Stack in this project

This project assumes you already have a hosted zone with the appropriate records DNS challenge records.

LetsencryptUpdaterEcsStack

cdk deploy LetsencryptUpdaterEcsStack

LetsencryptUpdaterStack

This stack creates an ec2 instance with userdata that installs certbot and prepares to run the commands in the section below.

By default this stack expects an SSH key named 'cjlyth-aws'

TODO

  • Create a stopped instance that has userdata to run the certbot create command
  • Create a stopped instance that has userdata to run the certbot renew command
  • Make the SSH key name a parameter

Usage

cdk deploy LetsencryptUpdaterStack

Manual certificate management

The EC2 update method installs all of the tooling to run the following commands in the userdata.

The ECS version uses a docker image that has certbot installed.

Request a new certificate

certbot certonly -d chrislyth.io -d *.chrislyth.io --dns-route53 \
    --logs-dir /mnt/efs/fs1/letsencrypt/log/ \
    --config-dir /mnt/efs/fs1/letsencrypt/config/ \
    --work-dir /mnt/efs/fs1/letsencrypt/work/ \
    -m [email protected] \
    --agree-tos --non-interactive \
    --server https://acme-v02.api.letsencrypt.org/directory

Renew a new certificate

# certbot renew --dry-run \
    --logs-dir /mnt/efs/fs1/letsencrypt/log/ \
    --config-dir /mnt/efs/fs1/letsencrypt/config/ \
    --work-dir /mnt/efs/fs1/letsencrypt/work/ 

Useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

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.