All Projects → elct9620 → Rails Letsencrypt

elct9620 / Rails Letsencrypt

Licence: mit
The Let's Encrypt certificate manager for rails

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Rails Letsencrypt

Letsencrypt Rails Heroku
Automatic LetsEncrypt SSL certificates in your Rails app on Heroku.
Stars: ✭ 223 (+114.42%)
Mutual labels:  rails, letsencrypt
Ansible Rails
Ruby on Rails deployment using Ansible - with Lets Encrypt, Sidekiq, PostgreSQL, nginx & puma
Stars: ✭ 199 (+91.35%)
Mutual labels:  rails, letsencrypt
Acme Plugin
🔏 ACME protocol plugin for Ruby on Rails applications
Stars: ✭ 190 (+82.69%)
Mutual labels:  rails, letsencrypt
Letsencrypt heroku
Automated letsencrypt setup for heroku
Stars: ✭ 58 (-44.23%)
Mutual labels:  rails, letsencrypt
Activerecord Clean Db Structure
Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
Stars: ✭ 101 (-2.88%)
Mutual labels:  rails
Acme Dns Certbot Joohoi
Certbot client hook for acme-dns
Stars: ✭ 99 (-4.81%)
Mutual labels:  letsencrypt
Yabeda Rails
Yabeda plugin to collect basic metrics for Rails applications
Stars: ✭ 99 (-4.81%)
Mutual labels:  rails
Chef Acme
Chef cookbook to request SSL certificates at Let's Encrypt
Stars: ✭ 98 (-5.77%)
Mutual labels:  letsencrypt
Activestorage Aliyun
Wraps the Aliyun OSS as an Active Storage service.
Stars: ✭ 103 (-0.96%)
Mutual labels:  rails
Acme
Async ACME library written in PHP based on the Amp concurrency framework.
Stars: ✭ 102 (-1.92%)
Mutual labels:  letsencrypt
Material design lite Sass
Google's Material Design Lite with Material Icons and Roboto font for Ruby applications
Stars: ✭ 100 (-3.85%)
Mutual labels:  rails
Lol dba
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Stars: ✭ 1,363 (+1210.58%)
Mutual labels:  rails
Simple recommender
A simple recommendation engine for Rails/Postgres
Stars: ✭ 101 (-2.88%)
Mutual labels:  rails
Certbot Plugin Gandi
Certbot plugin for authentication using Gandi LiveDNS
Stars: ✭ 98 (-5.77%)
Mutual labels:  letsencrypt
Premailer Rails
CSS styled emails without the hassle.
Stars: ✭ 1,382 (+1228.85%)
Mutual labels:  rails
Comfy Blog
Blog Engine for ComfortableMexicanSofa (Rails 5.2+)
Stars: ✭ 98 (-5.77%)
Mutual labels:  rails
Test track
Server app for the TestTrack multi-platform split-testing and feature-gating system
Stars: ✭ 100 (-3.85%)
Mutual labels:  rails
React Activestorage Provider
A React component that allows easy file upload using ActiveStorage
Stars: ✭ 102 (-1.92%)
Mutual labels:  rails
Instagram api gem
A Ruby wrapper for the Instagram API
Stars: ✭ 100 (-3.85%)
Mutual labels:  rails
Simpacker
Use modern JavaScript build system in Rails.
Stars: ✭ 100 (-3.85%)
Mutual labels:  rails

LetsEncrypt Gem Version Build Status Coverage Status Code Climate

Provide manageable Let's Encrypt Certificate for Rails.

Requirement

  • Rails 5+
  • Ruby 2.5+

Installation

Puts this in your Gemfile:

gem 'rails-letsencrypt'

Run install migrations

rails generate lets_encrypt:install
rake db:migrate

Setup private key for Let's Encrypt API

rails generate lets_encrypt:register

Add acme-challenge mounts in config/routes.rb

mount LetsEncrypt::Engine => '/.well-known'

Configuration

Add a file to config/initializers/letsencrypt.rb and put below config you need.

LetsEncrypt.config do |config|
  # Using Let's Encrypt staging server or not
  # Default only `Rails.env.production? == true` will use Let's Encrypt production server.
  config.use_staging = true

  # Set the private key path
  # Default is locate at config/letsencrypt.key
  config.private_key_path = Rails.root.join('config', 'letsencrypt.key')

  # Use environment variable to set private key
  # If enable, the API Client will use `LETSENCRYPT_PRIVATE_KEY` as private key
  # Default is false
  config.use_env_key = false

  # Should sync certificate into redis
  # When using ngx_mruby to dynamic load certificate, this will be helpful
  # Default is false
  config.save_to_redis = false

  # The redis server url
  # Default is nil
  config.redis_url = 'redis://localhost:6379/1'

  # Enable it if you want to customize the model
  # Default is LetsEncrypt::Certificate
  #config.certificate_model = 'MyCertificate'
end

Usage

The SSL certificate setup depends on the web server, this gem can work with ngx_mruby or kong.

Certificate Model

Create

Add a new domain into the database.

cert = LetsEncrypt::Certificate.create(domain: 'example.com')
cert.get # alias  `verify && issue`

Verify

Makes a request to Let's Encrypt and verify domain

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.verify

Issue

Ask Let's Encrypt to issue a new certificate.

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.issue

Renew

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.renew

Status

Check a certificate is verified and issued.

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.active? # => true

Check a certificate is expired.

cert = LetsEncrypt::Certificate.find_by(domain: 'example.com')
cert.expired? # => false

Tasks

To renew a certificate, you can run renew task to renew coming expires certificates.

rake letsencrypt:renew

Jobs

If you are using Sidekiq or others, you can enqueue renew task daily.

LetsEncrypt::RenewCertificatesJob.perform_later

ngx_mruby

The setup is following this Article

Add config/initializers/letsencrypt.rb to add config to sync certificate.

LetsEncrypt.config do |config|
  config.redis_url = 'redis://localhost:6379/1'
  config.save_to_redis = true
end

Connect Redis when Nginx worker start

http {
  # ...
  mruby_init_worker_code '
    userdata = Userdata.new
    userdata.redis = Redis.new "127.0.0.1", 6379
    # If your redis database is not 0, please select a correct one
    userdata.redis.select 1
  ';
}

Setup SSL using mruby

server {
  listen 443 ssl;
  server_name _;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers HIGH:!aNULL:!MD5;
  ssl_certificate certs/dummy.crt;
  ssl_certificate_key certs/dummy.key;

  mruby_ssl_handshake_handler_code '
    ssl = Nginx::SSL.new
    domain = ssl.servername

    redis = Userdata.new.redis
    unless redis["#{domain}.crt"].nil? and redis["#{domain}.key"].nil?
      ssl.certificate_data = redis["#{domain}.crt"]
      ssl.certificate_key_data = redis["#{domain}.key"]
    end
  ';
}

Kong

Coming soon.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].