Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for specifying key type #320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ The following parameters are available in the `letsencrypt` class:
* [`agree_tos`](#-letsencrypt--agree_tos)
* [`unsafe_registration`](#-letsencrypt--unsafe_registration)
* [`config_dir`](#-letsencrypt--config_dir)
* [`key_type`](#-letsencrypt--key_type)
* [`key_size`](#-letsencrypt--key_size)
* [`elliptic_curve`](#-letsencrypt--elliptic_curve)
* [`certificates`](#-letsencrypt--certificates)
* [`renew_pre_hook_commands`](#-letsencrypt--renew_pre_hook_commands)
* [`renew_post_hook_commands`](#-letsencrypt--renew_post_hook_commands)
Expand Down Expand Up @@ -210,6 +212,14 @@ The path to the configuration directory.

Default value: `'/etc/letsencrypt'`

##### <a name="-letsencrypt--key_type"></a>`key_type`

Data type: `Enum['rsa', 'ecdsa']`

Type of private key

Default value: `'rsa'`

##### <a name="-letsencrypt--key_size"></a>`key_size`

Data type: `Integer[2048]`
Expand All @@ -218,6 +228,14 @@ Size for the RSA public key

Default value: `4096`

##### <a name="-letsencrypt--elliptic_curve"></a>`elliptic_curve`

Data type: `String[1]`

The SECG elliptic curve name to use

Default value: `'secp256r1'`

##### <a name="-letsencrypt--certificates"></a>`certificates`

Data type: `Hash[String[1],Hash]`
Expand Down Expand Up @@ -752,7 +770,9 @@ The following parameters are available in the `letsencrypt::certonly` defined ty
* [`letsencrypt_command`](#-letsencrypt--certonly--letsencrypt_command)
* [`additional_args`](#-letsencrypt--certonly--additional_args)
* [`environment`](#-letsencrypt--certonly--environment)
* [`key_type`](#-letsencrypt--certonly--key_type)
* [`key_size`](#-letsencrypt--certonly--key_size)
* [`elliptic_curve`](#-letsencrypt--certonly--elliptic_curve)
* [`manage_cron`](#-letsencrypt--certonly--manage_cron)
* [`cron_output`](#-letsencrypt--certonly--cron_output)
* [`cron_before_command`](#-letsencrypt--certonly--cron_before_command)
Expand Down Expand Up @@ -835,6 +855,14 @@ An optional array of environment variables

Default value: `[]`

##### <a name="-letsencrypt--certonly--key_type"></a>`key_type`

Data type: `Enum['rsa', 'ecdsa']`

Type of private key

Default value: `$letsencrypt::key_type`

##### <a name="-letsencrypt--certonly--key_size"></a>`key_size`

Data type: `Integer[2048]`
Expand All @@ -843,6 +871,14 @@ Size for the RSA public key

Default value: `$letsencrypt::key_size`

##### <a name="-letsencrypt--certonly--elliptic_curve"></a>`elliptic_curve`

Data type: `String[1]`

The SECG elliptic curve name to use

Default value: `$letsencrypt::elliptic_curve`

##### <a name="-letsencrypt--certonly--manage_cron"></a>`manage_cron`

Data type: `Boolean`
Expand Down
14 changes: 12 additions & 2 deletions manifests/certonly.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
# @param letsencrypt_command Command to run letsencrypt
# @param additional_args An array of additional command line arguments to pass to the `letsencrypt` command.
# @param environment An optional array of environment variables
# @param key_type Type of private key
# @param key_size Size for the RSA public key
# @param elliptic_curve The SECG elliptic curve name to use
# @param manage_cron
# Indicating whether or not to schedule cron job for renewal.
# Runs daily but only renews if near expiration, e.g. within 10 days.
Expand Down Expand Up @@ -128,7 +130,9 @@
Letsencrypt::Plugin $plugin = 'standalone',
Array[Stdlib::Unixpath] $webroot_paths = [],
String[1] $letsencrypt_command = $letsencrypt::command,
Enum['rsa', 'ecdsa'] $key_type = $letsencrypt::key_type,
Integer[2048] $key_size = $letsencrypt::key_size,
String[1] $elliptic_curve = $letsencrypt::elliptic_curve,
Array[String[1]] $additional_args = [],
Array[String[1]] $environment = [],
Boolean $manage_cron = false,
Expand All @@ -153,10 +157,16 @@
$title_nowc = regsubst($title, '^\*\.', '')

if $ensure == 'present' {
if $key_type == 'rsa' {
$key_args = "--rsa-key-size ${key_size}"
} else {
$key_args = "--elliptic-curve ${elliptic_curve}"
}

if ($custom_plugin) {
$default_args = "--text --agree-tos --non-interactive certonly --rsa-key-size ${key_size}"
$default_args = "--text --agree-tos --non-interactive certonly --key-type ${key_type} ${key_args}"
} else {
$default_args = "--text --agree-tos --non-interactive certonly --rsa-key-size ${key_size} -a ${plugin}"
$default_args = "--text --agree-tos --non-interactive certonly --key-type ${key_type} ${key_args} -a ${plugin}"
}
} else {
$default_args = '--text --agree-tos --non-interactive delete'
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
# @param agree_tos A flag to agree to the Let's Encrypt Terms of Service.
# @param unsafe_registration A flag to allow using the 'register-unsafely-without-email' flag.
# @param config_dir The path to the configuration directory.
# @param key_type Type of private key
# @param key_size Size for the RSA public key
# @param elliptic_curve The SECG elliptic curve name to use
# @param certificates A hash containing certificates. Each key is the title and each value is a hash, both passed to letsencrypt::certonly.
# @param renew_pre_hook_commands Array of commands to run in a shell before obtaining/renewing any certificates.
# @param renew_post_hook_commands Array of commands to run in a shell after attempting to obtain/renew certificates.
Expand Down Expand Up @@ -76,7 +78,9 @@
Boolean $manage_install = true,
Boolean $agree_tos = true,
Boolean $unsafe_registration = false,
Enum['rsa', 'ecdsa'] $key_type = 'rsa',
Integer[2048] $key_size = 4096,
String[1] $elliptic_curve = 'secp256r1',
Hash[String[1],Hash] $certificates = {},
# $renew_* should only be used in letsencrypt::renew (blame rspec)
Variant[String[1], Array[String[1]]] $renew_pre_hook_commands = [],
Expand Down
Loading