Skip to content

Commit 59ae7e3

Browse files
authored
Merge pull request #320 from martijndegouw/feature/keytype
Add support for specifying key type ECDSA
2 parents f0900c7 + 3a18d0b commit 59ae7e3

File tree

4 files changed

+88
-30
lines changed

4 files changed

+88
-30
lines changed

REFERENCE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ The following parameters are available in the `letsencrypt` class:
7777
* [`agree_tos`](#-letsencrypt--agree_tos)
7878
* [`unsafe_registration`](#-letsencrypt--unsafe_registration)
7979
* [`config_dir`](#-letsencrypt--config_dir)
80+
* [`key_type`](#-letsencrypt--key_type)
8081
* [`key_size`](#-letsencrypt--key_size)
82+
* [`elliptic_curve`](#-letsencrypt--elliptic_curve)
8183
* [`certificates`](#-letsencrypt--certificates)
8284
* [`renew_pre_hook_commands`](#-letsencrypt--renew_pre_hook_commands)
8385
* [`renew_post_hook_commands`](#-letsencrypt--renew_post_hook_commands)
@@ -214,6 +216,14 @@ The path to the configuration directory.
214216

215217
Default value: `'/etc/letsencrypt'`
216218

219+
##### <a name="-letsencrypt--key_type"></a>`key_type`
220+
221+
Data type: `Enum['rsa', 'ecdsa']`
222+
223+
Type of private key
224+
225+
Default value: `'rsa'`
226+
217227
##### <a name="-letsencrypt--key_size"></a>`key_size`
218228

219229
Data type: `Integer[2048]`
@@ -222,6 +232,14 @@ Size for the RSA public key
222232

223233
Default value: `4096`
224234

235+
##### <a name="-letsencrypt--elliptic_curve"></a>`elliptic_curve`
236+
237+
Data type: `String[1]`
238+
239+
The SECG elliptic curve name to use
240+
241+
Default value: `'secp256r1'`
242+
225243
##### <a name="-letsencrypt--certificates"></a>`certificates`
226244

227245
Data type: `Hash[String[1],Hash]`
@@ -899,7 +917,9 @@ The following parameters are available in the `letsencrypt::certonly` defined ty
899917
* [`letsencrypt_command`](#-letsencrypt--certonly--letsencrypt_command)
900918
* [`additional_args`](#-letsencrypt--certonly--additional_args)
901919
* [`environment`](#-letsencrypt--certonly--environment)
920+
* [`key_type`](#-letsencrypt--certonly--key_type)
902921
* [`key_size`](#-letsencrypt--certonly--key_size)
922+
* [`elliptic_curve`](#-letsencrypt--certonly--elliptic_curve)
903923
* [`manage_cron`](#-letsencrypt--certonly--manage_cron)
904924
* [`cron_output`](#-letsencrypt--certonly--cron_output)
905925
* [`cron_before_command`](#-letsencrypt--certonly--cron_before_command)
@@ -982,6 +1002,14 @@ An optional array of environment variables
9821002

9831003
Default value: `[]`
9841004

1005+
##### <a name="-letsencrypt--certonly--key_type"></a>`key_type`
1006+
1007+
Data type: `Enum['rsa', 'ecdsa']`
1008+
1009+
Type of private key
1010+
1011+
Default value: `$letsencrypt::key_type`
1012+
9851013
##### <a name="-letsencrypt--certonly--key_size"></a>`key_size`
9861014

9871015
Data type: `Integer[2048]`
@@ -990,6 +1018,14 @@ Size for the RSA public key
9901018

9911019
Default value: `$letsencrypt::key_size`
9921020

1021+
##### <a name="-letsencrypt--certonly--elliptic_curve"></a>`elliptic_curve`
1022+
1023+
Data type: `String[1]`
1024+
1025+
The SECG elliptic curve name to use
1026+
1027+
Default value: `$letsencrypt::elliptic_curve`
1028+
9931029
##### <a name="-letsencrypt--certonly--manage_cron"></a>`manage_cron`
9941030

9951031
Data type: `Boolean`

manifests/certonly.pp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@
8787
# @param letsencrypt_command Command to run letsencrypt
8888
# @param additional_args An array of additional command line arguments to pass to the `letsencrypt` command.
8989
# @param environment An optional array of environment variables
90+
# @param key_type Type of private key
9091
# @param key_size Size for the RSA public key
92+
# @param elliptic_curve The SECG elliptic curve name to use
9193
# @param manage_cron
9294
# Indicating whether or not to schedule cron job for renewal.
9395
# Runs daily but only renews if near expiration, e.g. within 10 days.
@@ -128,7 +130,9 @@
128130
Letsencrypt::Plugin $plugin = 'standalone',
129131
Array[Stdlib::Unixpath] $webroot_paths = [],
130132
String[1] $letsencrypt_command = $letsencrypt::command,
133+
Enum['rsa', 'ecdsa'] $key_type = $letsencrypt::key_type,
131134
Integer[2048] $key_size = $letsencrypt::key_size,
135+
String[1] $elliptic_curve = $letsencrypt::elliptic_curve,
132136
Array[String[1]] $additional_args = [],
133137
Array[String[1]] $environment = [],
134138
Boolean $manage_cron = false,
@@ -153,10 +157,16 @@
153157
$title_nowc = regsubst($title, '^\*\.', '')
154158

155159
if $ensure == 'present' {
160+
if $key_type == 'rsa' {
161+
$key_args = "--rsa-key-size ${key_size}"
162+
} else {
163+
$key_args = "--elliptic-curve ${elliptic_curve}"
164+
}
165+
156166
if ($custom_plugin) {
157-
$default_args = "--text --agree-tos --non-interactive certonly --rsa-key-size ${key_size}"
167+
$default_args = "--text --agree-tos --non-interactive certonly --key-type ${key_type} ${key_args}"
158168
} else {
159-
$default_args = "--text --agree-tos --non-interactive certonly --rsa-key-size ${key_size} -a ${plugin}"
169+
$default_args = "--text --agree-tos --non-interactive certonly --key-type ${key_type} ${key_args} -a ${plugin}"
160170
}
161171
} else {
162172
$default_args = '--text --agree-tos --non-interactive delete'

manifests/init.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
# @param agree_tos A flag to agree to the Let's Encrypt Terms of Service.
2828
# @param unsafe_registration A flag to allow using the 'register-unsafely-without-email' flag.
2929
# @param config_dir The path to the configuration directory.
30+
# @param key_type Type of private key
3031
# @param key_size Size for the RSA public key
32+
# @param elliptic_curve The SECG elliptic curve name to use
3133
# @param certificates A hash containing certificates. Each key is the title and each value is a hash, both passed to letsencrypt::certonly.
3234
# @param renew_pre_hook_commands Array of commands to run in a shell before obtaining/renewing any certificates.
3335
# @param renew_post_hook_commands Array of commands to run in a shell after attempting to obtain/renew certificates.
@@ -80,7 +82,9 @@
8082
Boolean $manage_install = true,
8183
Boolean $agree_tos = true,
8284
Boolean $unsafe_registration = false,
85+
Enum['rsa', 'ecdsa'] $key_type = 'rsa',
8386
Integer[2048] $key_size = 4096,
87+
String[1] $elliptic_curve = 'secp256r1',
8488
Hash[String[1],Hash] $certificates = {},
8589
# $renew_* should only be used in letsencrypt::renew (blame rspec)
8690
Variant[String[1], Array[String[1]]] $renew_pre_hook_commands = [],

0 commit comments

Comments
 (0)