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.

499 lines
15 KiB

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