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.

773 lines
23 KiB

5 years ago
4 years ago
  1. .\" Copyright (c) 2019-2020 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 September 19, 2020
  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. .Pp
  33. Unix style globing is supported.
  34. .It Ic global
  35. Table containing the global configuration options.
  36. .Bl -tag
  37. .It Cm accounts_directory Ar string
  38. Specify the directory where the accounts private and public keys are stored.
  39. .It Cm certificates_directory Ar string
  40. Specify the directory where the certificates and their associated private keys are stored.
  41. .It Cm cert_file_mode Ar integer
  42. Specify the permissions to use for newly-created certificates files. See
  43. .Xr chmod 2
  44. for more details.
  45. .It Cm cert_file_user Ar username|user_id Ft string
  46. Specify the user who will own newly-created certificates files. See
  47. .Xr chown 2
  48. for more details.
  49. .It Cm cert_file_group Ar group_name|group_id Ft string
  50. Specify the group who will own newly-created certificates files. See
  51. .Xr chown 2
  52. for more details.
  53. .It Ic env Ar table
  54. Table of environment variables that will be accessible from hooks.
  55. .It Cm pk_file_mode Ar integer
  56. Specify the permissions to use for newly-created private-key files. See
  57. .Xr chmod 2
  58. for more details.
  59. .It Cm pk_file_user Ar username|user_id Ft string
  60. Specify the user who will own newly-created private-key files. See
  61. .Xr chown 2
  62. for more details.
  63. .It Cm pk_file_group Ar group_name|group_id Ft string
  64. Specify the group who will own newly-created private-key files. See
  65. .Xr chown 2
  66. for more details.
  67. .It Cm renew_delay Ar string
  68. Period of time between the certificate renewal and its expiration date. The format is described in the
  69. .Sx TIME PERIODS
  70. section. Default is 3w.
  71. .El
  72. .It Ic rate-limit
  73. Array of table where each element defines a HTTPS rate limit.
  74. .Bl -tag
  75. .It Cm name Ar string
  76. The name the rate limit is registered under. Must be unique.
  77. .It Cm number Ar integer
  78. Number of requests authorized withing the time period.
  79. .It Cm period Ar string
  80. Period of time during which a maximal number of requests is authorized. The format is described in the
  81. .Sx TIME PERIODS
  82. section.
  83. .El
  84. .It Ic endpoint
  85. Array of table where each element defines a Certificate Authority
  86. .Pq CA
  87. which may be used to request certificates.
  88. .Bl -tag
  89. .It Cm name Ar string
  90. The name the endpoint is registered under. Must be unique.
  91. .It Cm rate_limits Ar array
  92. Array containing the names of the HTTPS rate limits to apply.
  93. .It Cm tos_agreed Ar boolean
  94. Set whether or not the user agrees to the Terms Of Service
  95. .Pq TOS .
  96. .It Cm url Ar string
  97. The endpoint's directory URL.
  98. .It Cm renew_delay Ar string
  99. Period of time between the certificate renewal and its expiration date. The format is described in the
  100. .Sx TIME PERIODS
  101. section. Default is the value defined in the global section.
  102. .El
  103. .It Ic hook
  104. Array of table where each element defines a command that will be launched at a defined point. See section
  105. .Sx WRITING A HOOK
  106. for more details.
  107. .Bl -tag
  108. .It Cm allow_failure Ar boolean
  109. Defines if an error return value for this hook is allowed or not. If not allowed, a failure in this hook will fail the whole certificate request process. Default is false.
  110. .It Cm name Ar string
  111. The name the hook is registered under. Must be unique.
  112. .It Cm type Ar array
  113. Array of strings. Possible types are:
  114. .Bl -dash -compact
  115. .It
  116. challenge-http-01
  117. .It
  118. challenge-http-01-clean
  119. .It
  120. challenge-dns-01
  121. .It
  122. challenge-dns-01-clean
  123. .It
  124. challenge-tls-alpn-01
  125. .It
  126. challenge-tls-alpn-01-clean
  127. .It
  128. file-pre-create
  129. .It
  130. file-pre-edit
  131. .It
  132. file-post-create
  133. .It
  134. file-post-edit
  135. .It
  136. post-operation
  137. .El
  138. .It Ic cmd Ar string
  139. The name of the command that will be launched.
  140. .It Ic args Ar array
  141. Array of strings representing the command's arguments.
  142. .It Ic stdin Ar string
  143. Path to the file that will be written into the command's standard intput. Mutually exclusive with
  144. .Em stdin_str .
  145. .It Ic stdin_str Ar string
  146. String that will be written into the command's standard input. Mutually exclusive with
  147. .Em stdin .
  148. .It Ic stdout Ar string
  149. Path to the file where the command's standard output if written.
  150. .It Ic stderr Ar string
  151. Path to the file where the command's standard error output if written.
  152. .El
  153. .It Ic group
  154. Array of table allowing to group several hooks as one. A group is considered as new hook.
  155. .Bl -tag
  156. .It Cm name Ar string
  157. The name the group is registered under. This name is considered as a hook name. Must be unique.
  158. .It Cm hooks Ar array
  159. Array containing the names of the hooks that are grouped. The hooks are guaranteed to be called sequentially in the declaration order.
  160. .El
  161. .It Ic account
  162. Array of table representing an account on one or several endpoint.
  163. .Bl -tag
  164. .It Ic name Ar string
  165. The name the account is registered under. Must be unique.
  166. .It Ic contacts Ar array
  167. Array of tables describing describing the account holder's contact information. Each table must have one and only one key-value pair. Possible keys and their associated values are:
  168. .Bl -tag
  169. .It Ic mailto Ar string
  170. A mailto URI as defined by
  171. .Em RFC 6068 .
  172. This URI cannot contains neither "hfields" nor more than one "addr-spec" in the "to" component.
  173. .El
  174. .It Cm key_type Ar string
  175. Name of the asymmetric cryptography algorithm used to generate the key pair. Possible values are:
  176. .Bl -dash -compact
  177. .It
  178. rsa2048
  179. .It
  180. rsa4096
  181. .It
  182. ecdsa_p256
  183. .Aq default
  184. .It
  185. ecdsa_p384
  186. .It
  187. ecdsa_p521
  188. .El
  189. .It Cm signature_algorithm Ar string
  190. Name of the signature algorithm used to sign the messages sent to the endpoint as defined in
  191. .Em RFC 7518 .
  192. The default value is derived from the key type. Possible values are:
  193. .Bl -dash -compact
  194. .It
  195. RS256
  196. .It
  197. ES256
  198. .It
  199. ES384
  200. .It
  201. ES512
  202. .El
  203. .It Ic env Ar table
  204. Table of environment variables that will be accessible from hooks.
  205. .It Ic hooks Ar array
  206. Names of hooks that will be called during operations on the account storage file. The hooks are guaranteed to be called sequentially in the declaration order.
  207. .It Ic external_account Ar table
  208. Table containing the information required to bind the account to an external one. Possible fields and values are:
  209. .Bl -tag
  210. .It Ic identifier Ar string
  211. ASCII string identifying the key.
  212. .It Ic key Ar string
  213. Private key encoded in base64url without padding.
  214. .It Ic signature_algorithm Ar string
  215. Name of the signature algorithm used to sign the external account binding message sent to the endpoint as defined in
  216. .Em RFC 7518 .
  217. Possible values are:
  218. .Bl -dash -compact
  219. .It
  220. HS256
  221. .Aq default
  222. .It
  223. HS384
  224. .It
  225. HS512
  226. .El
  227. .El
  228. .El
  229. .It Ic certificate
  230. Array of table representing a certificate that will be requested to a CA.
  231. .Pp
  232. Note that certificates are identified by the first identifier in the list of identifiers. That means that if you reorder the identifiers so that a different identifier is at the first position, a new certificate with a new name will be issued.
  233. .Bl -tag
  234. .It Ic account Ar string
  235. Name of the account to use.
  236. .It Ic endpoint Ar string
  237. Name of the endpoint to use.
  238. .It Ic env Ar table
  239. Table of environment variables that will be accessible from hooks.
  240. .It Ic identifiers Ar array
  241. Array of tables listing the identifiers that should be included in the certificate along with the challenge to use for each one. The
  242. .Em dns
  243. and
  244. .Em ip
  245. fields are mutually exclusive.
  246. .Bl -tag
  247. .It Ic challenge Ar string
  248. The name of the challenge to use to prove the identifier's ownership. Possible values are:
  249. .Bl -dash -compact
  250. .It
  251. http-01
  252. .It
  253. dns-01
  254. .It
  255. tls-alpn-01
  256. .El
  257. .It Ic dns Ar string
  258. The domain name.
  259. .It Ic ip Ar string
  260. The IP address.
  261. .It Ic env Ar table
  262. Table of environment variables that will be accessible from hooks.
  263. .El
  264. .It subject_attributes Ar table
  265. Table where the certificate's subject attributes are specified. Possible keys are:
  266. .Bl -dash -compact
  267. .It
  268. country_name
  269. .It
  270. locality_name
  271. .It
  272. state_or_province_name
  273. .It
  274. street_address
  275. .It
  276. organization_name
  277. .It
  278. organizational_unit_name
  279. .It
  280. name
  281. .It
  282. given_name
  283. .It
  284. initials
  285. .It
  286. title
  287. .It
  288. surname
  289. .It
  290. pseudonym
  291. .It
  292. generation_qualifier
  293. .It
  294. friendly_name
  295. .El
  296. .It Ic key_type Ar string
  297. Name of the asymmetric cryptography algorithm used to generate the certificate's key pair. Possible values are:
  298. .Bl -dash -compact
  299. .It
  300. rsa2048
  301. .Aq default
  302. .It
  303. rsa4096
  304. .It
  305. ecdsa_p256
  306. .It
  307. ecdsa_p384
  308. .It
  309. ecdsa_p521
  310. .El
  311. .It Ic csr_digest Ar string
  312. Name of the certificate's signing request digest algorithm. Possible values are:
  313. .Bl -dash -compact
  314. .It
  315. sha256
  316. .Aq default
  317. .It
  318. sha384
  319. .It
  320. sha512
  321. .El
  322. .It Ic kp_reuse Ar boolean
  323. Set whether or not the private key should be reused when renewing the certificate. Default is false.
  324. .It Ic directory Ar string
  325. Path to the directory where certificates and their associated private keys are stored.
  326. .It Ic hooks Ar array
  327. Names of hooks that will be called when requesting a new certificate. The hooks are guaranteed to be called sequentially in the declaration order.
  328. .It Cm renew_delay Ar string
  329. Period of time between the certificate renewal and its expiration date. The format is described in the
  330. .Sx TIME PERIODS
  331. section. Default is the value defined in the associated endpoint.
  332. .El
  333. .Sh WRITING A HOOK
  334. When requesting a certificate from a CA using ACME, there are three steps that are hard to automatize. The first one is solving challenges in order to prove the ownership of every identifier 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 use 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.
  335. .Pp
  336. In order to allow full automation of the three above steps without imposing arbitrary restrictions or methods,
  337. .Xr acmed 8
  338. uses hooks. Fundamentally, a hook is a command line template that will be called at a specific time of the process. Such an approach allows admins to use any executable script or program located on the machine to customize the process.
  339. .Pp
  340. 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.
  341. .Pp
  342. A hook has 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.
  343. .Pp
  344. When writing a hook, the values of
  345. .Em args ,
  346. .Em stdin ,
  347. .Em stdin_str ,
  348. .Em stdout
  349. and
  350. .Em stderr
  351. are considered as template strings whereas
  352. .Em cmd
  353. is not. The template syntax is
  354. .Em Handlebars .
  355. See the
  356. .Sx STANDARDS
  357. section for a link to the
  358. .Em Handlebars
  359. specifications.
  360. .Pp
  361. The available types and the associated template variable are described below.
  362. .Bl -tag
  363. .It Ic challenge-http-01
  364. Invoked when the ownership of an identifier must be proved using the
  365. .Em http-01
  366. challenge. The available template variables are:
  367. .Bl -tag -compact
  368. .It Cm challenge Ar string
  369. The name of the challenge type
  370. .Aq http-01 .
  371. Mostly used in hooks with multiple types.
  372. .It Cm identifier Ar string
  373. The identifier name whom ownership is currently being validated.
  374. .It Cm identifier_tls_alpn Ar string
  375. The identifier name whom ownership is currently being validated, in a form suitable for the TLS ALPN challenge.
  376. .It Cm env Ar array
  377. Array containing all the environment variables.
  378. .It Cm file_name Ar string
  379. Name of the file containing the proof. This is not a full path and does not include the
  380. .Ql .well-known/acme-challenge/
  381. prefix.
  382. .It Cm is_clean_hook Ar bool
  383. False
  384. .It Cm proof Ar string
  385. The content of the proof that must be written to
  386. .Em file_name .
  387. .El
  388. .It Ic challenge-http-01-clean
  389. Invoked once an identifier ownership has been proven using the
  390. .Em http-01
  391. 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
  392. .Em challenge-http-01
  393. hook, excepted
  394. .Em is_clean_hook
  395. which is set to
  396. .Em true .
  397. .It Ic challenge-dns-01
  398. Invoked when the ownership of an identifier must be proved using the
  399. .Em dns-01
  400. challenge. The available template variables are:
  401. .Bl -tag -compact
  402. .It Cm challenge Ar string
  403. The name of the challenge type
  404. .Aq dns-01 .
  405. Mostly used in hooks with multiple types.
  406. .It Cm identifier Ar string
  407. The identifier name whom ownership is currently being validated.
  408. .It Cm identifier_tls_alpn Ar string
  409. The identifier name whom ownership is currently being validated, in a form suitable for the TLS ALPN challenge.
  410. .It Cm env Ar array
  411. Array containing all the environment variables.
  412. .It Cm is_clean_hook Ar bool
  413. False
  414. .It Cm proof Ar string
  415. The content of the proof that must be written to a
  416. .Ql TXT
  417. entry of the DNS zone for the
  418. .Ql _acme-challenge
  419. subdomain.
  420. .El
  421. .It Ic challenge-dns-01-clean
  422. Invoked once an identifier ownership has been proven using the
  423. .Em dns-01
  424. 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
  425. .Em challenge-dns-01
  426. hook, excepted
  427. .Em is_clean_hook
  428. which is set to
  429. .Em true .
  430. .It Ic challenge-tls-alpn-01
  431. Invoked when the ownership of an identifier must be proved using the
  432. .Em tls-alpn-01
  433. challenge. The available template variables are:
  434. .Bl -tag -compact
  435. .It Cm challenge Ar string
  436. The name of the challenge type
  437. .Aq tls-alpn-01 .
  438. Mostly used in hooks with multiple types.
  439. .It Cm identifier Ar string
  440. The identifier name whom ownership is currently being validated.
  441. .It Cm identifier_tls_alpn Ar string
  442. The identifier name whom ownership is currently being validated, in a form suitable for the TLS ALPN challenge.
  443. .It Cm env Ar array
  444. Array containing all the environment variables.
  445. .It Cm is_clean_hook Ar bool
  446. False
  447. .It Cm proof Ar string
  448. Plain-text representation of the
  449. .Em acmeIdentifier
  450. extension that should be used in the self-signed certificate presented when a TLS connection is initiated with the
  451. .Qd acme-tls/1
  452. ALPN extension value.
  453. .Xr acmed 8
  454. will not generate the certificate itself since it can be done using
  455. .Xr tacd 8 .
  456. .El
  457. .It Ic challenge-tls-alpn-01-clean
  458. Invoked once an identifier ownership has been proven using the
  459. .Em tls-alpn-01
  460. 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
  461. .Em challenge-tls-alpn-01
  462. hook, excepted
  463. .Em is_clean_hook
  464. which is set to
  465. .Em true .
  466. .It Ic file-pre-create
  467. Invoked
  468. .Em before
  469. a non-existent file
  470. .Em created .
  471. The available template variables are:
  472. .Bl -tag -compact
  473. .It Cm env Ar array
  474. Array containing all the environment variables.
  475. .It Cm file_directory Ar string
  476. Name of the directory where the impacted file is located.
  477. .It Cm file_name Ar string
  478. Name of the impacted file.
  479. .It Cm file_path Ar string
  480. Full path to the impacted file.
  481. .El
  482. .It Ic file-pre-edit
  483. Invoked
  484. .Em before
  485. an existent file
  486. .Em modified .
  487. The available template variables are the same as those available for the
  488. .Em file-pre-create
  489. type.
  490. .It Ic file-post-create
  491. Invoked
  492. .Em after
  493. a non-existent file
  494. .Em created .
  495. The available template variables are the same as those available for the
  496. .Em file-pre-create
  497. type.
  498. .It Ic file-post-edit
  499. Invoked
  500. .Em after
  501. an existent file
  502. .Em modified .
  503. The available template variables are the same as those available for the
  504. .Em file-pre-create
  505. type.
  506. .It Ic post-operation
  507. Invoked at the end of the certificate request process. The available template variables are:
  508. .Bl -tag -compact
  509. .It Cm key_type Ar string
  510. Name of the asymmetric cryptography algorithm used to generate the certificate's key pair.
  511. .It Cm identifiers Ar string
  512. Array containing the identifiers included in the requested certificate.
  513. .It Cm env Ar array
  514. Array containing all the environment variables.
  515. .It Cm is_success Ar boolean
  516. True if the certificate request is successful.
  517. .It Cm status Ar string
  518. Human-readable status. If the certificate request failed, it contains the error description.
  519. .El
  520. .El
  521. .Sh DEFAULT HOOKS
  522. Because many people have the same needs, ACMEd comes with a set of hooks that should serve most situations. Hook names being unique, the following names and any other name starting by those is reserved and should not be used.
  523. .Bl -tag
  524. .It Pa git
  525. This hook uses
  526. .Xr git 1
  527. to archive private keys, public keys and certificates. It is possible to customize the commit username and email by using respectively the
  528. .Ev GIT_USERNAME
  529. and
  530. .Ev GIT_EMAIL
  531. environment variables.
  532. .It Pa http-01-echo
  533. This hook is designed to solve the http-01 challenge. For this purpose, it will write the proof into
  534. .Pa {{env.HTTP_ROOT}}/{{identifier}}/.well-known/acme-challenge/{{file_name}} .
  535. .Pp
  536. The web server must be configured so the file
  537. .Pa http://{{identifier}}/.well-known/acme-challenge/{{file_name}}
  538. can be accessed from the CA.
  539. .Pp
  540. If
  541. .Ev HTTP_ROOT
  542. is not specified, it will be set to
  543. .Pa /var/www .
  544. .It Pa tls-alpn-01-tacd-tcp
  545. This hook is designed to solve the tls-alpn-01 challenge using
  546. .Xr tacd 8 .
  547. It requires
  548. .Xr pkill 1
  549. to support the
  550. .Em Ar -F
  551. option.
  552. .Pp
  553. .Xr tacd 8
  554. will listen on the host defined by the
  555. .Ev TACD_HOST
  556. environment variable (default is the identifier to be validated) and on the port defined by the
  557. .Ev TACD_PORT
  558. environment variable (default is 5001).
  559. .Pp
  560. .Xr tacd 8
  561. will store its pid into
  562. .Pa {{TACD_PID_ROOT}}/tacd_{{identifier}}.pid .
  563. If
  564. .Ev TACD_PID_ROOT
  565. is not specified, it will be set to
  566. .Pa /run .
  567. .It Pa tls-alpn-01-tacd-unix
  568. This hook is designed to solve the tls-alpn-01 challenge using
  569. .Xr tacd 8 .
  570. It requires
  571. .Xr pkill 1
  572. to support the
  573. .Em Ar -F
  574. option.
  575. .Pp
  576. .Xr tacd 8
  577. will listen on the unix socket
  578. .Pa {{env.TACD_SOCK_ROOT}}/tacd_{{identifier}}.sock .
  579. If
  580. .Ev TACD_SOCK_ROOT
  581. is not specified, it will be set to
  582. .Pa /run .
  583. .Pp
  584. .Xr tacd 8
  585. will store its pid into
  586. .Pa {{TACD_PID_ROOT}}/tacd_{{identifier}}.pid .
  587. If
  588. .Ev TACD_PID_ROOT
  589. is not specified, it will be set to
  590. .Pa /run .
  591. .El
  592. .Sh TIME PERIODS
  593. ACMEd uses its own time period format, which is vaguely inspired by the ISO 8601 one. Periods are formatted as
  594. .Ar PM[PM...]
  595. where
  596. .Ar M
  597. is case sensitive character representing a length and
  598. .Ar P
  599. is an integer representing a multiplayer for the following length. The authorized length are:
  600. .Bl -dash -compact
  601. .It
  602. .Ar s :
  603. second
  604. .It
  605. .Ar m :
  606. minute
  607. .It
  608. .Ar h :
  609. hour
  610. .It
  611. .Ar d :
  612. day
  613. .It
  614. .Ar w :
  615. week
  616. .El
  617. The
  618. .Ar PM
  619. couples can be specified multiple times and in any order.
  620. .Pp
  621. For example,
  622. .Dq 1d42s and
  623. .Dq 40s20h4h2s
  624. both represents a period of one day and forty-two seconds.
  625. .Sh FILES
  626. .Bl -tag
  627. .It Pa /etc/acmed/acmed.toml
  628. Default
  629. .Xr acmed 8
  630. configuration file.
  631. .It Pa /etc/acmed/accounts
  632. Default accounts private and public keys directory.
  633. .It Pa /etc/acmed/certs
  634. Default certificates and associated private keys directory.
  635. .Sh EXAMPLES
  636. The following example defines a typical endpoint, account and certificate for a domain, several subdomains and an IP address.
  637. .Bd -literal -offset indent
  638. [[endpoint]]
  639. name = "example name"
  640. url = "https://acme.example.org/directory"
  641. tos_agreed = true
  642. [[account]]
  643. name = "my test account"
  644. email = "certs@exemple.net"
  645. [[certificate]]
  646. endpoint = "example name"
  647. account = "my test account"
  648. identifiers = [
  649. { dns = "exemple.net", challenge = "http-01"},
  650. { dns = "1.exemple.net", challenge = "dns-01"},
  651. { dns = "2.exemple.net", challenge = "tls-alpn-01", env.TACD_PORT="5010"},
  652. { dns = "3.exemple.net", challenge = "tls-alpn-01", env.TACD_PORT="5011"},
  653. { ip = "203.0.113.1", challenge = "http-01"},
  654. ]
  655. hooks = ["git", "http-01-echo", "tls-alpn-01-tacd-tcp", "some-dns-01-hook"]
  656. env.HTTP_ROOT = "/srv/http"
  657. .Ed
  658. .Pp
  659. It is possible to use
  660. .Xr echo 1
  661. to solve the
  662. .Em http-01
  663. challenge and
  664. .Xr rm 1
  665. to clean it.
  666. .Xr mkdir 1
  667. and
  668. .Xr chmod 1
  669. are used to prevent issues related to file access.
  670. .Bd -literal -offset indent
  671. [[hook]]
  672. name = "http-01-echo-mkdir"
  673. type = ["challenge-http-01"]
  674. cmd = "mkdir"
  675. args = [
  676. "-m", "0755",
  677. "-p", "{{%if env.HTTP_ROOT}}{{env.HTTP_ROOT}}{{else}}/var/www{{/if}}/{{identifier}}/.well-known/acme-challenge"
  678. ]
  679. [[hook]]
  680. name = "http-01-echo-echo"
  681. type = ["challenge-http-01"]
  682. cmd = "echo"
  683. args = ["{{proof}}"]
  684. stdout = "{{%if env.HTTP_ROOT}}{{env.HTTP_ROOT}}{{else}}/var/www{{/if}}/{{identifier}}/.well-known/acme-challenge/{{file_name}}"
  685. [[hook]]
  686. name = "http-01-echo-chmod"
  687. type = ["challenge-http-01-clean"]
  688. cmd = "chmod"
  689. args = [
  690. "a+r",
  691. "{{%if env.HTTP_ROOT}}{{env.HTTP_ROOT}}{{else}}/var/www{{/if}}/{{identifier}}/.well-known/acme-challenge/{{file_name}}"
  692. ]
  693. [[hook]]
  694. name = "http-01-echo-clean"
  695. type = ["challenge-http-01-clean"]
  696. cmd = "rm"
  697. args = [
  698. "-f",
  699. "{{%if env.HTTP_ROOT}}{{env.HTTP_ROOT}}{{else}}/var/www{{/if}}/{{identifier}}/.well-known/acme-challenge/{{file_name}}"
  700. ]
  701. .Ed
  702. .Pp
  703. The hooks from the previous example can be grouped in order to reduce the number of hooks to define in the certificate.
  704. .Bd -literal -offset indent
  705. [[group]]
  706. name = "http-01-echo-var-www"
  707. hooks = [
  708. "http-01-echo-mkdir",
  709. "http-01-echo-echo",
  710. "http-01-echo-chmod",
  711. "http-01-echo-clean"
  712. ]
  713. [[certificate]]
  714. # Some fields omitted
  715. hooks = ["http-01-echo"]
  716. env.HTTP_ROOT = "/srv/http"
  717. .Ed
  718. .Pp
  719. It is also possible to use
  720. .Xr sendmail 8
  721. in a hook in order to notif someone when the certificate request process is done.
  722. .Bd -literal -offset indent
  723. [[hook]]
  724. name = "email-report"
  725. type = ["post-operation"]
  726. cmd = "sendmail"
  727. args = [
  728. "-f", "noreply.certs@example.net",
  729. "contact@example.net"
  730. ]
  731. stdin_str = """Subject: Certificate renewal {{#if is_success}}succeeded{{else}}failed{{/if}} for {{identifiers.[0]}}
  732. The following certificate has {{#unless is_success}}*not* {{/unless}}been renewed.
  733. identifiers: {{#each identifiers}}{{#if @index}}, {{/if}}{{this}}{{/each}}
  734. key type: {{key_type}}
  735. status: {{status}}"""
  736. .Ed
  737. .Sh SEE ALSO
  738. .Xr acmed 8 ,
  739. .Xr tacd 8
  740. .Sh STANDARDS
  741. .Bl
  742. .It
  743. .Rs
  744. .%A Tom Preston-Werner
  745. .%D July 2018
  746. .%T TOML v0.5.0
  747. .%U https://github.com/toml-lang/toml
  748. .Re
  749. .It
  750. .Rs
  751. .%A Yehuda Katz
  752. .%T Handlebars
  753. .%U https://handlebarsjs.com/
  754. .Re
  755. .It
  756. .Rs
  757. .%A M. Jones
  758. .%D May 2015
  759. .%R RFC 7518
  760. .%T JSON Web Algorithms (JWA)
  761. .Re
  762. .El
  763. .Sh AUTHORS
  764. .An Rodolphe Bréard
  765. .Aq rodolphe@breard.tf