Version information
This version is compatible with:
- , , , , , ,
This module has been deprecated by its author since May 15th 2020.
The author has suggested bzed-dehydrated as its replacement.
Start using this module
Documentation
DEPRECATED!
bzed-letsencrypt is deprecated! Please use bzed-dehydrated instead!
letsencrypt
Table of Contents
- Overview
- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with letsencrypt
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Overview
Centralized CSR signing using Let’s Encrypt™ - keeping your keys safe on the host they belong to.
Module Description
bzed-letsencrypy creates private keys and CSRs, transfers the CSR to a puppetmaster where it is signed using the well known dehydrated https://github.com/lukas2511/dehydrated
Signed certificates are shipped back to the appropriate host.
You need to provide an appropriate hook script for letsencryt.sh, The default is to use the DNS-01 challenge, but if you hook supports it you could also create the necessary files for http-01.
Let’s Encrypt is a trademark of the Internet Security Research Group. All rights reserved.
Setup
What letsencrypt affects
- dehydrated is running at the puppetmaster host as it is easier to read and work with certificate files stored directly on the puppet master. Retrieving them using facter is unnecessarily complicated.
Setup Requirements
You need to ensure that exported ressources are working and pluginsync is enabled.
Beginning with letsencrypt
In the best case: add the letsencrypt class and override $domains with a list of domains you want to get certificates for.
Usage
On puppet nodes
On a puppet node where you need your certificates:
class { 'letsencrypt' :
domains => [ 'foo.example.com', 'fuzz.example.com' ],
}
Key and CSR will be generated on your node and the CSR is shipped to your puppetmaster for signing - the puppetmaster needs a public interface and the cert is put on your node after some time.
Additionally to or instead of specifying the domains as parameter to the letsencrypt class, it is possible to call the letsencrypt::certificate define directly:
::letsencrypt::certificate { 'foo.example.com' :
}
SAN Certificates
Requesting SAN certificates is also possible. To do so pass a space seperated list of domainnames into the domains array. The first domainname in each list is used as the base domain for the request. For example:
class { 'letsencrypt' :
domains => [
'foo.example.com bar.example.com good.example.com',
'fuzz.example.com'
],
}
And/or:
::letsencrypt::certificate { 'foo.example.com bar.example.com good.example.com' :
}
On your puppetmaster:
What you need to prepare is a hook you want to use with dehydrated as you need to deploy the challenges somehow. Various examples for valid DNS-01 hooks are listed on https://github.com/lukas2511/dehydrated/wiki/Examples-for-DNS-01-hooks
class { 'letsencrypt' :
hook_source => 'puppet:///modules/mymodule/dehydrated_hook'
}
CSRs are collected and signed, and the resulting certificates and CA chain files are shipped back to your node.
Testing and Debugging
For testing purposes you want to use the staging CA, otherwise you'll hit rate limits pretty soon. To do s set the letsencrypt_ca option:
class { 'letsencrypt' :
hook_source => 'puppet:///modules/mymodule/dehydrated_hook',
letsencrypt_ca => 'staging',
}
Examples
Postfix
Using the camptocamp-postfix module:
require ::letsencrypt::params
$myhostname = $::fqdn
$base_dir = $::letsencrypt::params::base_dir
$crt_dir = $::letsencrypt::params::crt_dir
$key_dir = $::letsencrypt::params::key_dir
$postfix_chroot = '/var/spool/postfix'
$tls_key = "${key_dir}/${myhostname}.key"
$tls_cert = "${crt_dir}/${myhostname}_fullchain.pem"
::letsencrypt::certificate { $myhostname :
notify => Service['postfix'],
}
::postfix::config { 'smtpd_tls_cert_file' :
value => $tls_cert,
require => Letsencrypt::Certificate[$myhostname]
}
::postfix::config { 'smtpd_tls_key_file' :
value => $tls_key,
require => Letsencrypt::Certificate[$myhostname]
}
::postfix::config { 'smtpd_use_tls' :
value => 'yes'
}
::postfix::config { 'smtpd_tls_session_cache_database' :
value => "btree:\${data_directory}/smtpd_scache",
}
::postfix::config { 'smtp_tls_session_cache_database' :
value => "btree:\${data_directory}/smtp_scache",
}
::postfix::config { 'smtp_tls_security_level' :
value => 'may',
}
file { [
"${postfix_chroot}/${base_dir}",
"${postfix_chroot}/${crt_dir}",
] :
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
file { "${postfix_chroot}/${key_dir}" :
ensure => directory,
owner => 'root',
group => 'root',
mode => '0750',
}
file { "${postfix_chroot}/${tls_key}" :
ensure => file,
owner => 'root',
group => 'root',
mode => '0640',
source => $tls_key,
subscribe => Letsencrypt::Certificate[$myhostname],
notify => Service['postfix'],
}
file { "${postfix_chroot}/${tls_cert}" :
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
source => $tls_cert,
subscribe => Letsencrypt::Certificate[$myhostname],
notify => Service['postfix'],
}
Reference
Classes:
- letsencrypt
- letsencrypt::params
- letsencrypt::request::handler
Defines:
- letsencrypt::csr
- letsencrypt::deploy
- letsencrypt::deploy::crt
- letsencrypt::request
- letsencrypt::request::crt
Facts:
- letsencrypt_csrs
- letsencrypt_csr_*
- letsencrypt_crts
Limitations
Not really well tested yet, documentation missing, no spec tests....
Development
Patches are very welcome! Please send your pull requests on github!
Release 0.1.17
###Summary
- Last bugfix release before the module will be renamed to bzed-dehydrated.
####Bugfixes
- Rubocop / travis-ci fixes
- Inherit class params from params.pp
Release 0.1.16
###Summary
- letsencrypt.sh was renamed to dehydrated. This release makes bzed-letsencrypt work with dehydrated while staying compatible as much as possible.
- I'll follow the rename - bzed-letsencrypt will be renamed to bzed-dehydrated before somebody tries to force me to do so. I understand that Let’s Encrypt™ needs to enforce their trademark, but they should find a better way to handle these issues.
####Features
- Use 'dehydrated'.
####Bugfixes
- Various little bugfixes
Release 0.1.15
###Summary
- Bugfix release
- Better Puppetserver support
####Bugfixes
- Various minor bugfixes, typo fixes.
####Improvements
- Better variable validation
- Use puppetserver variables automatically
Release 0.1.14
###Summary
- Introduce letsencrypt::certificate
####Improvements
- With the new letsencrypt::certificate it is now possible to request certificates from other puppet modules. Subscribing to the define or receiving notifications from it is also possible.
- Add an usage example to README.md, showing how to use letsencrypt::certificate with camptocamp-postfix.
Release 0.1.13
###Summary
- Bugfix-only release.
####Bugfixes
- Don't require User['letsencrypt'] on clients - its only available on puppet masters.
Release 0.1.12
###Summary
- Avoid dh parameter generation on the puppet master host.
####Bugfixes
- Add missing dependency on puppetlabs-vcsrepo.
####Improvements
- Create dh files on the puppet client, not master. Made possible by requiring an uptodate concat version.
Release 0.1.11
###Summary
- Bugfix-only release.
####Bugfixes
- Ensure we're compatible to older releases.
- Remove some unused code.
Release 0.1.10
###Summary
- The 'OCSP' release.
####Features
- Retrieve and ship OCSP stapling information into .crt.ocsp files.
####Bugfixes
- Remove old crt chain / dh files.
####Improvements
- Use file_concat to build the full-key-chain file.
Release 0.1.9
###Summary
- The 'SAN-certificate' release.
####Features
- Allow to use http/https proxies with letsencrypt.sh
- Handle different letsencrypt CA URLs, useful for testing/debugging with the staging CA.
- Passing a contact email for the letsencrypt registration is possible now, too.
####Bugfixes
- Various minor bugs
####Improvements
- Fix various issues in the openssl certificate config file.
- Handle the private_key.json file, keeping the registration information on disk.
Release 0.1.8
###Summary
- Generate full chain .pem file, including the key.
Release 0.1.7
###Summary
- Fixing typos / documentation.
Release 0.1.6
###Summary
- Create .dh files
Release 0.1.5
###Summary
- Fixing typos / documentation.
Release 0.1.4
###Summary
- Add basic travis.ci checks
- Make rubocop and puppet-lint happy.
Release 0.1.3
###Summary
- Actually deploy the ca chain certificate
- Add gitignore file.
- Fixing typos / documentation.
Release 0.1.2
###Summary
- Fixing typos / documentation.
- Handle empty certificate chain files
- Various fixes
Release 0.1.1
###Summary
- First working release.
Dependencies
- puppetlabs-stdlib (>= 2.2.0)
- puppetlabs-concat (>= 2.1.0)
- puppetlabs-vcsrepo (>= 1.3.2)
- camptocamp-openssl (>= 1.5.1)