You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

463 lines
14 KiB

  1. .\" Copyright (c) 2019 Rodolphe Bréard <rodolphe@breard.tf>
  2. .\"
  3. .\" Copying and distribution of this file, with or without modification,
  4. .\" are permitted in any medium without royalty provided the copyright
  5. .\" notice and this notice are preserved. This file is offered as-is,
  6. .\" without any warranty.
  7. .Dd May 3, 2019
  8. .Dt ACMED.TOML 5
  9. .Os
  10. .Sh NAME
  11. .Nm acmed.toml
  12. .Nd ACMEd configuration file
  13. .Sh DESCRIPTION
  14. .Nm
  15. is the configuration file for
  16. .Xr acmed 8 .
  17. It is written in the
  18. .Em TOML
  19. format. The allowed elements are described below.
  20. .Bl -tag
  21. .It Ic global
  22. Table containing the global configuration options.
  23. .Bl -tag
  24. .It Cm accounts_directory Ar string
  25. Specify the directory where the accounts private and public keys are stored.
  26. .It Cm certificates_directory Ar string
  27. Specify the directory where the certificates and their associated private keys are stored.
  28. .It Cm cert_file_mode Ar integer
  29. Specify the permissions to use for newly-created certificates files. See
  30. .Xr chmod 2
  31. for more details.
  32. .It Cm cert_file_user Ar user_id Ft string
  33. Specify the user who will own newly-created certificates files. See
  34. .Xr chown 2
  35. for more details.
  36. .It Cm cert_file_group Ar group_id Ft string
  37. Specify the group who will own newly-created certificates files. See
  38. .Xr chown 2
  39. for more details.
  40. .It Cm pk_file_mode Ar integer
  41. Specify the permissions to use for newly-created private-key files. See
  42. .Xr chmod 2
  43. for more details.
  44. .It Cm pk_file_user Ar user_id Ft string
  45. Specify the user who will own newly-created private-key files. See
  46. .Xr chown 2
  47. for more details.
  48. .It Cm pk_file_group Ar group_id Ft string
  49. Specify the group who will own newly-created private-key files. See
  50. .Xr chown 2
  51. for more details.
  52. .El
  53. .It Ic endpoint
  54. Array of table where each element defines a Certificate Authority
  55. .Pq CA
  56. which may be used to request certificates.
  57. .Bl -tag
  58. .It Cm name Ar string
  59. The name the endpoint is registered under. Must be unique.
  60. .It Cm url Ar string
  61. The endpoint's directory URL.
  62. .It Cm tos_agreed Ar boolean
  63. Set whether or not the user agrees to the Terms Of Service
  64. .Pq TOS .
  65. .El
  66. .It Ic hook
  67. Array of table where each element defines a command that will be launched at a defined point. See section
  68. .Sx WRITING A HOOK
  69. for more details.
  70. .Bl -tag
  71. .It Cm name Ar string
  72. The name the hook is registered under. Must be unique.
  73. .It Cm hook_type Ar array
  74. Array of strings. Possible types are:
  75. .Bl -dash -compact
  76. .It
  77. challenge-http-01
  78. .It
  79. challenge-http-01-clean
  80. .It
  81. challenge-dns-01
  82. .It
  83. challenge-dns-01-clean
  84. .It
  85. challenge-tls-alpn-01
  86. .It
  87. challenge-tls-alpn-01-clean
  88. .It
  89. file-pre-create
  90. .It
  91. file-pre-edit
  92. .It
  93. file-post-create
  94. .It
  95. file-post-edit
  96. .It
  97. post-operation
  98. .El
  99. .It Ic cmd Ar string
  100. The name of the command that will be launched.
  101. .It Ic args Ar array
  102. Array of strings representing the command's arguments.
  103. .It Ic stdin Ar string
  104. String that will be written into the command's standard input.
  105. .It Ic stdout Ar string
  106. Path to the file where the command's standard output if written.
  107. .It Ic stderr Ar string
  108. Path to the file where the command's standard error output if written.
  109. .El
  110. .It Ic group
  111. Array of table allowing to group several hooks as one. A group is considered as new hook.
  112. .Bl -tag
  113. .It Cm name Ar string
  114. The name the group is registered under. This name is considered as a hook name. Must be unique.
  115. .It Cm hooks Ar array
  116. Array containing the names of the hooks that are grouped. The hooks are guaranteed to be called sequentially in the declaration order.
  117. .El
  118. .It Ic account
  119. Array of table representing an account on one or several CA.
  120. .Bl -tag
  121. .It Ic name Ar string
  122. The name the account is registered under. Must be unique.
  123. .It Ic email Ar string
  124. The email address used to contact the account's holder.
  125. .El
  126. .It Ic certificate
  127. Array of table representing a certificate that will be requested to a CA.
  128. .Bl -tag
  129. .It Ic account Ar string
  130. Name of the account to use.
  131. .It Ic endpoint Ar string
  132. Name of the endpoint to use.
  133. .It Ic domains Ar array
  134. Array of tables listing the domains that should be included in the certificate along with the challenge to use for each one.
  135. .Bl -tag
  136. .It Ic dns
  137. The domain name.
  138. .It Ic challenge
  139. The name of the challenge to use to prove the domain's ownership. Possible values are:
  140. .Bl -dash -compact
  141. .It
  142. http-01
  143. .It
  144. dns-01
  145. .It
  146. tls-alpn-01
  147. .El
  148. .El
  149. .It Ic algorithm Ar string
  150. Name of the asymetric cryptography algorithm used to generate the certificate's key pair. Possible values are :
  151. .Bl -dash -compact
  152. .It
  153. rsa2048
  154. .Aq default
  155. .It
  156. rsa4096
  157. .It
  158. ecdsa_p256
  159. .It
  160. ecdsa_p384
  161. .El
  162. .It Ic kp_reuse Ar boolean
  163. Set whether or not the private key should be reused when renewing the certificate. Default is false.
  164. .It Ic directory Ar string
  165. Path to the directory where certificates and their associated private keys are stored.
  166. .It Ic hooks Ar array
  167. Names of hooks that will be called when requesting a new certificate. The hooks are guaranteed to be called sequentially in the declaration order.
  168. .El
  169. .Sh WRITING A HOOK
  170. When requesting a certificate to a CA using ACME, there is three steps that are hard to automatize. The first one is solving challenges in order to prove the ownership of every domains to be included: it requires to interact with the configuration of other services, hence depends on how the infrastructure works. The second one is restarting all the services that uses a given certificate, for the same reason. The last one is archiving: although several default methods can be implemented, sometimes admins wants or are required to do it in a different way.
  171. .Pp
  172. In order to allow a full automation of the three above steps without imposing arbitrary restrictions or methods,
  173. .Xr acmed 8
  174. uses hooks. Fundamentally, a hook is a command line template that will be called at a specific time of the process. Such approach allows admins to use any executable script or program located on the machine to customize the process.
  175. .Pp
  176. For a given certificate, hooks are guaranteed to be called sequentially in the declaration order. It is therefore possible to have a hook that depends on another one. Nevertheless, several certificates may be renewed at the same time. Hence, hooks shall not use globing or any other action that may disrupt hooks called by a different certificate.
  177. .Pp
  178. A hook have a type that will influence both the moment it is called and the available template variables. It is possible to declare several types. In such a case, the hook will be invoked whenever one of its type request it. When called, the hook only have access to template variable for the current type. If a hook uses a template variable that does not exists for the current type it is invoked for, the variable is empty.
  179. .Pp
  180. When writing a hook, the values of
  181. .Em args ,
  182. .Em stdin ,
  183. .Em stdout
  184. and
  185. .Em stderr
  186. are considered as template strings whereas
  187. .Em cmd
  188. is not. The template syntax is
  189. .Em Handlebars .
  190. See the
  191. .Sx STANDARDS
  192. section for a link to the
  193. .Em Handlebars
  194. specifications.
  195. .Pp
  196. The available types and the associated template variable are described below.
  197. .Bl -tag
  198. .It Ic challenge-http-01
  199. Invoked when the ownership of a domain must be proved using the
  200. .Em http-01
  201. challenge. The available template variables are:
  202. .Bl -tag -compact
  203. .It Cm domain Ar string
  204. The domain name whom ownership is currently being validated.
  205. .It Cm challenge Ar string
  206. The name of the challenge type
  207. .Aq http-01 .
  208. Mostly used in hooks with multiple types.
  209. .It Cm file_name Ar string
  210. Name of the file containing the proof. This is not a full path and does not include the
  211. .Ql .well-known/acme-challenge/
  212. prefix.
  213. .It Cm proof Ar string
  214. The content of the proof that must be written to
  215. .Em file_name .
  216. .El
  217. .It Ic challenge-http-01-clean
  218. Invoked once a domain ownership has been proven using the
  219. .Em http-01
  220. challenge. This hook is intended to remove the proof since it is no longer required. The template variables are strictly identical to those given in the corresponding
  221. .Em challenge-http-01
  222. hook.
  223. .It Ic challenge-dns-01
  224. Invoked when the ownership of a domain must be proved using the
  225. .Em dns-01
  226. challenge. The available template variables are:
  227. .Bl -tag -compact
  228. .It Cm domain Ar string
  229. The domain name whom ownership is currently being validated.
  230. .It Cm challenge Ar string
  231. The name of the challenge type
  232. .Aq dns-01 .
  233. Mostly used in hooks with multiple types.
  234. .It Cm proof Ar string
  235. The content of the proof that must be written to a
  236. .Ql TXT
  237. entry of the DNS zone for the
  238. .Ql _acme-challenge
  239. subdomain.
  240. .El
  241. .It Ic challenge-dns-01-clean
  242. Invoked once a domain ownership has been proven using the
  243. .Em dns-01
  244. challenge. This hook is intended to remove the proof since it is no longer required. The template variables are strictly identical to those given in the corresponding
  245. .Em challenge-dns-01
  246. hook.
  247. .It Ic challenge-tls-alpn-01
  248. Invoked when the ownership of a domain must be proved using the
  249. .Em tls-alpn-01
  250. challenge. The available template variables are:
  251. .Bl -tag -compact
  252. .It Cm domain Ar string
  253. The domain name whom ownership is currently being validated.
  254. .It Cm challenge Ar string
  255. The name of the challenge type
  256. .Aq tls-alpn-01 .
  257. Mostly used in hooks with multiple types.
  258. .It Cm proof Ar string
  259. Plain-text representation of the
  260. .Em acmeIdentifier
  261. extension that should be used in the self-signed certificate presented when a TLS connection is initiated with the
  262. .Qd acme-tls/1
  263. ALPN extension value.
  264. .Xr acmed 8
  265. will not generate the certificate itself since it can be done using
  266. .Xr tacd 8 .
  267. .El
  268. .It Ic challenge-tls-alpn-01-clean
  269. Invoked once a domain ownership has been proven using the
  270. .Em tls-alpn-01
  271. challenge. This hook is intended to remove the proof since it is no longer required. The template variables are strictly identical to those given in the corresponding
  272. .Em challenge-tls-alpn-01
  273. hook.
  274. .It Ic file-pre-create
  275. Invoked
  276. .Em before
  277. a non-existent file
  278. .Em created .
  279. The available template variables are:
  280. .Bl -tag -compact
  281. .It Cm file_name Ar string
  282. Name of the impacted file.
  283. .It Cm file_directory Ar string
  284. Name of the directory where the impacted file is located.
  285. .It Cm file_path Ar string
  286. Full path to the impacted file.
  287. .El
  288. .It Ic file-pre-edit
  289. Invoked
  290. .Em before
  291. an existent file
  292. .Em modified .
  293. The available template variables are the same as those available for the
  294. .Em file-pre-create
  295. type.
  296. .It Ic file-post-create
  297. Invoked
  298. .Em after
  299. a non-existent file
  300. .Em created .
  301. The available template variables are the same as those available for the
  302. .Em file-pre-create
  303. type.
  304. .It Ic file-post-edit
  305. Invoked
  306. .Em after
  307. an existent file
  308. .Em modified .
  309. The available template variables are the same as those available for the
  310. .Em file-pre-create
  311. type.
  312. .It Ic post-operation
  313. Invoked at the end of the certificate request process. The available template variables are:
  314. .Bl -tag -compact
  315. .It Cm domains Ar string
  316. Array containing the domain names included in the requested certificate.
  317. .It Cm algorithm Ar string
  318. Name of the algorithm used in the certificate.
  319. .It Cm status Ar string
  320. Status of request. Is set to
  321. .Dq Success.
  322. in case the operation succeeded, in an error description otherwise.
  323. .El
  324. .El
  325. .Sh FILES
  326. .Bl -tag
  327. .It Pa /etc/acmed/acmed.toml
  328. Default
  329. .Xr acmed 8
  330. configuration file.
  331. .It Pa /etc/acmed/accounts
  332. Default accounts private and public keys directory.
  333. .It Pa /etc/acmed/certs
  334. Default certificates and associated private keys directory.
  335. .Sh EXAMPLES
  336. The following example defines a typical endpoint, account and certificate for a domain and several subdomains.
  337. .Bd -literal -offset indent
  338. [[endpoint]]
  339. name = "example name"
  340. url = "https://acme.example.org/directory"
  341. tos_agreed = true
  342. [[account]]
  343. name = "my test account"
  344. email = "certs@exemple.net"
  345. [[certificate]]
  346. endpoint = "example name"
  347. account = "my test account"
  348. domains = [
  349. { dns = "exemple.net", challenge = "http-01"},
  350. { dns = "1.exemple.net", challenge = "http-01"},
  351. { dns = "2.exemple.net", challenge = "dns-01"},
  352. { dns = "3.exemple.net", challenge = "tls-alpn-01"},
  353. ]
  354. hooks = ["example-hook-1", "example-hook-2", "example-hook-3"]
  355. .Ed
  356. .Pp
  357. It is possible to use
  358. .Xr echo 1
  359. to solve the
  360. .Em http-01
  361. challenge and
  362. .Xr rm 1
  363. to clean it.
  364. .Xr mkdir 1
  365. and
  366. .Xr chmod 1
  367. are used to prevent issues related to file access.
  368. .Bd -literal -offset indent
  369. [[hook]]
  370. name = "http-01-echo-mkdir"
  371. type = ["challenge-http-01"]
  372. cmd = "mkdir"
  373. args = [
  374. "-m", "0755",
  375. "-p", "/var/www/{{domain}}/.well-known/acme-challenge"
  376. ]
  377. [[hook]]
  378. name = "http-01-echo-echo"
  379. type = ["challenge-http-01"]
  380. cmd = "echo"
  381. args = ["{{proof}}"]
  382. stdout = "/var/www/{{domain}}/.well-known/acme-challenge/{{file_name}}"
  383. [[hook]]
  384. name = "http-01-echo-chmod"
  385. type = ["challenge-http-01-clean"]
  386. cmd = "chmod"
  387. args = [
  388. "a+r",
  389. "/var/www/{{domain}}/.well-known/acme-challenge/{{file_name}}"
  390. ]
  391. [[hook]]
  392. name = "http-01-echo-clean"
  393. type = ["challenge-http-01-clean"]
  394. cmd = "rm"
  395. args = [
  396. "-f",
  397. "/var/www/{{domain}}/.well-known/acme-challenge/{{file_name}}"
  398. ]
  399. .Ed
  400. .Pp
  401. The hooks from the previous example can be grouped in order to reduce the number of hooks to define in the certificate.
  402. .Bd -literal -offset indent
  403. [[group]]
  404. name = "http-01-echo-var-www"
  405. hooks = [
  406. "http-01-echo-mkdir",
  407. "http-01-echo-echo",
  408. "http-01-echo-chmod",
  409. "http-01-echo-clean"
  410. ]
  411. [[certificate]]
  412. # Some fields omitted
  413. hooks = ["http-01-echo-var-www"]
  414. .Ed
  415. .Pp
  416. It is also possible to use
  417. .Xr sendmail 8
  418. in a hook in order to notif someone when the certificate request process is done.
  419. .Bd -literal -offset indent
  420. [[hook]]
  421. name = "email-report"
  422. type = ["post-operation"]
  423. cmd = "sendmail"
  424. args = [
  425. "-f", "noreply.certs@example.net",
  426. "contact@example.net"
  427. ]
  428. stdin = """Subject: Certificate renewal alert for {{domains.[0]}}
  429. The following certificate has been renewed.
  430. domains: {{#each domains}}{{#if @index}}, {{/if}}{{this}}{{/each}}
  431. algorithm: {{algorithm}}
  432. status: {{status}}"""
  433. .Ed
  434. .Sh SEE ALSO
  435. .Xr acmed 8 ,
  436. .Xr tacd 8
  437. .Sh STANDARDS
  438. .Bl
  439. .It
  440. .Rs
  441. .%A Tom Preston-Werner
  442. .%D July 2018
  443. .%T TOML v0.5.0
  444. .%U https://github.com/toml-lang/toml
  445. .Re
  446. .It
  447. .Rs
  448. .%A Yehuda Katz
  449. .%T Handlebars
  450. .%U https://handlebarsjs.com/
  451. .Re
  452. .El
  453. .Sh AUTHORS
  454. .An Rodolphe Bréard
  455. .Aq rodolphe@breard.tf