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.

767 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. .El
  187. .It Cm signature_algorithm Ar string
  188. Name of the signature algorithm used to sign the messages sent to the endpoint as defined in
  189. .Em RFC 7518 .
  190. The default value is derived from the key type. Possible values are:
  191. .Bl -dash -compact
  192. .It
  193. RS256
  194. .It
  195. ES256
  196. .It
  197. ES384
  198. .El
  199. .It Ic env Ar table
  200. Table of environment variables that will be accessible from hooks.
  201. .It Ic hooks Ar array
  202. 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.
  203. .It Ic external_account Ar table
  204. Table containing the information required to bind the account to an external one. Possible fields and values are:
  205. .Bl -tag
  206. .It Ic identifier Ar string
  207. ASCII string identifying the key.
  208. .It Ic key Ar string
  209. Private key encoded in base64url without padding.
  210. .It Ic signature_algorithm Ar string
  211. Name of the signature algorithm used to sign the external account binding message sent to the endpoint as defined in
  212. .Em RFC 7518 .
  213. Possible values are:
  214. .Bl -dash -compact
  215. .It
  216. HS256
  217. .Aq default
  218. .It
  219. HS384
  220. .It
  221. HS512
  222. .El
  223. .El
  224. .El
  225. .It Ic certificate
  226. Array of table representing a certificate that will be requested to a CA.
  227. .Pp
  228. 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.
  229. .Bl -tag
  230. .It Ic account Ar string
  231. Name of the account to use.
  232. .It Ic endpoint Ar string
  233. Name of the endpoint to use.
  234. .It Ic env Ar table
  235. Table of environment variables that will be accessible from hooks.
  236. .It Ic identifiers Ar array
  237. Array of tables listing the identifiers that should be included in the certificate along with the challenge to use for each one. The
  238. .Em dns
  239. and
  240. .Em ip
  241. fields are mutually exclusive.
  242. .Bl -tag
  243. .It Ic challenge Ar string
  244. The name of the challenge to use to prove the identifier's ownership. Possible values are:
  245. .Bl -dash -compact
  246. .It
  247. http-01
  248. .It
  249. dns-01
  250. .It
  251. tls-alpn-01
  252. .El
  253. .It Ic dns Ar string
  254. The domain name.
  255. .It Ic ip Ar string
  256. The IP address.
  257. .It Ic env Ar table
  258. Table of environment variables that will be accessible from hooks.
  259. .El
  260. .It subject_attributes Ar table
  261. Table where the certificate's subject attributes are specified. Possible keys are:
  262. .Bl -dash -compact
  263. .It
  264. country_name
  265. .It
  266. locality_name
  267. .It
  268. state_or_province_name
  269. .It
  270. street_address
  271. .It
  272. organization_name
  273. .It
  274. organizational_unit_name
  275. .It
  276. name
  277. .It
  278. given_name
  279. .It
  280. initials
  281. .It
  282. title
  283. .It
  284. surname
  285. .It
  286. pseudonym
  287. .It
  288. generation_qualifier
  289. .It
  290. friendly_name
  291. .El
  292. .It Ic key_type Ar string
  293. Name of the asymmetric cryptography algorithm used to generate the certificate's key pair. Possible values are:
  294. .Bl -dash -compact
  295. .It
  296. rsa2048
  297. .Aq default
  298. .It
  299. rsa4096
  300. .It
  301. ecdsa_p256
  302. .It
  303. ecdsa_p384
  304. .El
  305. .It Ic csr_digest Ar string
  306. Name of the certificate's signing request digest algorithm. Possible values are:
  307. .Bl -dash -compact
  308. .It
  309. sha256
  310. .Aq default
  311. .It
  312. sha384
  313. .It
  314. sha512
  315. .El
  316. .It Ic kp_reuse Ar boolean
  317. Set whether or not the private key should be reused when renewing the certificate. Default is false.
  318. .It Ic directory Ar string
  319. Path to the directory where certificates and their associated private keys are stored.
  320. .It Ic hooks Ar array
  321. Names of hooks that will be called when requesting a new certificate. The hooks are guaranteed to be called sequentially in the declaration order.
  322. .It Cm renew_delay Ar string
  323. Period of time between the certificate renewal and its expiration date. The format is described in the
  324. .Sx TIME PERIODS
  325. section. Default is the value defined in the associated endpoint.
  326. .El
  327. .Sh WRITING A HOOK
  328. 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.
  329. .Pp
  330. In order to allow full automation of the three above steps without imposing arbitrary restrictions or methods,
  331. .Xr acmed 8
  332. 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.
  333. .Pp
  334. 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.
  335. .Pp
  336. 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.
  337. .Pp
  338. When writing a hook, the values of
  339. .Em args ,
  340. .Em stdin ,
  341. .Em stdin_str ,
  342. .Em stdout
  343. and
  344. .Em stderr
  345. are considered as template strings whereas
  346. .Em cmd
  347. is not. The template syntax is
  348. .Em Handlebars .
  349. See the
  350. .Sx STANDARDS
  351. section for a link to the
  352. .Em Handlebars
  353. specifications.
  354. .Pp
  355. The available types and the associated template variable are described below.
  356. .Bl -tag
  357. .It Ic challenge-http-01
  358. Invoked when the ownership of an identifier must be proved using the
  359. .Em http-01
  360. challenge. The available template variables are:
  361. .Bl -tag -compact
  362. .It Cm challenge Ar string
  363. The name of the challenge type
  364. .Aq http-01 .
  365. Mostly used in hooks with multiple types.
  366. .It Cm identifier Ar string
  367. The identifier name whom ownership is currently being validated.
  368. .It Cm identifier_tls_alpn Ar string
  369. The identifier name whom ownership is currently being validated, in a form suitable for the TLS ALPN challenge.
  370. .It Cm env Ar array
  371. Array containing all the environment variables.
  372. .It Cm file_name Ar string
  373. Name of the file containing the proof. This is not a full path and does not include the
  374. .Ql .well-known/acme-challenge/
  375. prefix.
  376. .It Cm is_clean_hook Ar bool
  377. False
  378. .It Cm proof Ar string
  379. The content of the proof that must be written to
  380. .Em file_name .
  381. .El
  382. .It Ic challenge-http-01-clean
  383. Invoked once an identifier ownership has been proven using the
  384. .Em http-01
  385. 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
  386. .Em challenge-http-01
  387. hook, excepted
  388. .Em is_clean_hook
  389. which is set to
  390. .Em true .
  391. .It Ic challenge-dns-01
  392. Invoked when the ownership of an identifier must be proved using the
  393. .Em dns-01
  394. challenge. The available template variables are:
  395. .Bl -tag -compact
  396. .It Cm challenge Ar string
  397. The name of the challenge type
  398. .Aq dns-01 .
  399. Mostly used in hooks with multiple types.
  400. .It Cm identifier Ar string
  401. The identifier name whom ownership is currently being validated.
  402. .It Cm identifier_tls_alpn Ar string
  403. The identifier name whom ownership is currently being validated, in a form suitable for the TLS ALPN challenge.
  404. .It Cm env Ar array
  405. Array containing all the environment variables.
  406. .It Cm is_clean_hook Ar bool
  407. False
  408. .It Cm proof Ar string
  409. The content of the proof that must be written to a
  410. .Ql TXT
  411. entry of the DNS zone for the
  412. .Ql _acme-challenge
  413. subdomain.
  414. .El
  415. .It Ic challenge-dns-01-clean
  416. Invoked once an identifier ownership has been proven using the
  417. .Em dns-01
  418. 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
  419. .Em challenge-dns-01
  420. hook, excepted
  421. .Em is_clean_hook
  422. which is set to
  423. .Em true .
  424. .It Ic challenge-tls-alpn-01
  425. Invoked when the ownership of an identifier must be proved using the
  426. .Em tls-alpn-01
  427. challenge. The available template variables are:
  428. .Bl -tag -compact
  429. .It Cm challenge Ar string
  430. The name of the challenge type
  431. .Aq tls-alpn-01 .
  432. Mostly used in hooks with multiple types.
  433. .It Cm identifier Ar string
  434. The identifier name whom ownership is currently being validated.
  435. .It Cm identifier_tls_alpn Ar string
  436. The identifier name whom ownership is currently being validated, in a form suitable for the TLS ALPN challenge.
  437. .It Cm env Ar array
  438. Array containing all the environment variables.
  439. .It Cm is_clean_hook Ar bool
  440. False
  441. .It Cm proof Ar string
  442. Plain-text representation of the
  443. .Em acmeIdentifier
  444. extension that should be used in the self-signed certificate presented when a TLS connection is initiated with the
  445. .Qd acme-tls/1
  446. ALPN extension value.
  447. .Xr acmed 8
  448. will not generate the certificate itself since it can be done using
  449. .Xr tacd 8 .
  450. .El
  451. .It Ic challenge-tls-alpn-01-clean
  452. Invoked once an identifier ownership has been proven using the
  453. .Em tls-alpn-01
  454. 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
  455. .Em challenge-tls-alpn-01
  456. hook, excepted
  457. .Em is_clean_hook
  458. which is set to
  459. .Em true .
  460. .It Ic file-pre-create
  461. Invoked
  462. .Em before
  463. a non-existent file
  464. .Em created .
  465. The available template variables are:
  466. .Bl -tag -compact
  467. .It Cm env Ar array
  468. Array containing all the environment variables.
  469. .It Cm file_directory Ar string
  470. Name of the directory where the impacted file is located.
  471. .It Cm file_name Ar string
  472. Name of the impacted file.
  473. .It Cm file_path Ar string
  474. Full path to the impacted file.
  475. .El
  476. .It Ic file-pre-edit
  477. Invoked
  478. .Em before
  479. an existent file
  480. .Em modified .
  481. The available template variables are the same as those available for the
  482. .Em file-pre-create
  483. type.
  484. .It Ic file-post-create
  485. Invoked
  486. .Em after
  487. a non-existent file
  488. .Em created .
  489. The available template variables are the same as those available for the
  490. .Em file-pre-create
  491. type.
  492. .It Ic file-post-edit
  493. Invoked
  494. .Em after
  495. an existent file
  496. .Em modified .
  497. The available template variables are the same as those available for the
  498. .Em file-pre-create
  499. type.
  500. .It Ic post-operation
  501. Invoked at the end of the certificate request process. The available template variables are:
  502. .Bl -tag -compact
  503. .It Cm key_type Ar string
  504. Name of the asymmetric cryptography algorithm used to generate the certificate's key pair.
  505. .It Cm identifiers Ar string
  506. Array containing the identifiers included in the requested certificate.
  507. .It Cm env Ar array
  508. Array containing all the environment variables.
  509. .It Cm is_success Ar boolean
  510. True if the certificate request is successful.
  511. .It Cm status Ar string
  512. Human-readable status. If the certificate request failed, it contains the error description.
  513. .El
  514. .El
  515. .Sh DEFAULT HOOKS
  516. 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.
  517. .Bl -tag
  518. .It Pa git
  519. This hook uses
  520. .Xr git 1
  521. to archive private keys, public keys and certificates. It is possible to customize the commit username and email by using respectively the
  522. .Ev GIT_USERNAME
  523. and
  524. .Ev GIT_EMAIL
  525. environment variables.
  526. .It Pa http-01-echo
  527. This hook is designed to solve the http-01 challenge. For this purpose, it will write the proof into
  528. .Pa {{env.HTTP_ROOT}}/{{identifier}}/.well-known/acme-challenge/{{file_name}} .
  529. .Pp
  530. The web server must be configured so the file
  531. .Pa http://{{identifier}}/.well-known/acme-challenge/{{file_name}}
  532. can be accessed from the CA.
  533. .Pp
  534. If
  535. .Ev HTTP_ROOT
  536. is not specified, it will be set to
  537. .Pa /var/www .
  538. .It Pa tls-alpn-01-tacd-tcp
  539. This hook is designed to solve the tls-alpn-01 challenge using
  540. .Xr tacd 8 .
  541. It requires
  542. .Xr pkill 1
  543. to support the
  544. .Em Ar -F
  545. option.
  546. .Pp
  547. .Xr tacd 8
  548. will listen on the host defined by the
  549. .Ev TACD_HOST
  550. environment variable (default is the identifier to be validated) and on the port defined by the
  551. .Ev TACD_PORT
  552. environment variable (default is 5001).
  553. .Pp
  554. .Xr tacd 8
  555. will store its pid into
  556. .Pa {{TACD_PID_ROOT}}/tacd_{{identifier}}.pid .
  557. If
  558. .Ev TACD_PID_ROOT
  559. is not specified, it will be set to
  560. .Pa /run .
  561. .It Pa tls-alpn-01-tacd-unix
  562. This hook is designed to solve the tls-alpn-01 challenge using
  563. .Xr tacd 8 .
  564. It requires
  565. .Xr pkill 1
  566. to support the
  567. .Em Ar -F
  568. option.
  569. .Pp
  570. .Xr tacd 8
  571. will listen on the unix socket
  572. .Pa {{env.TACD_SOCK_ROOT}}/tacd_{{identifier}}.sock .
  573. If
  574. .Ev TACD_SOCK_ROOT
  575. is not specified, it will be set to
  576. .Pa /run .
  577. .Pp
  578. .Xr tacd 8
  579. will store its pid into
  580. .Pa {{TACD_PID_ROOT}}/tacd_{{identifier}}.pid .
  581. If
  582. .Ev TACD_PID_ROOT
  583. is not specified, it will be set to
  584. .Pa /run .
  585. .El
  586. .Sh TIME PERIODS
  587. ACMEd uses its own time period format, which is vaguely inspired by the ISO 8601 one. Periods are formatted as
  588. .Ar PM[PM...]
  589. where
  590. .Ar M
  591. is case sensitive character representing a length and
  592. .Ar P
  593. is an integer representing a multiplayer for the following length. The authorized length are:
  594. .Bl -dash -compact
  595. .It
  596. .Ar s :
  597. second
  598. .It
  599. .Ar m :
  600. minute
  601. .It
  602. .Ar h :
  603. hour
  604. .It
  605. .Ar d :
  606. day
  607. .It
  608. .Ar w :
  609. week
  610. .El
  611. The
  612. .Ar PM
  613. couples can be specified multiple times and in any order.
  614. .Pp
  615. For example,
  616. .Dq 1d42s and
  617. .Dq 40s20h4h2s
  618. both represents a period of one day and forty-two seconds.
  619. .Sh FILES
  620. .Bl -tag
  621. .It Pa /etc/acmed/acmed.toml
  622. Default
  623. .Xr acmed 8
  624. configuration file.
  625. .It Pa /etc/acmed/accounts
  626. Default accounts private and public keys directory.
  627. .It Pa /etc/acmed/certs
  628. Default certificates and associated private keys directory.
  629. .Sh EXAMPLES
  630. The following example defines a typical endpoint, account and certificate for a domain, several subdomains and an IP address.
  631. .Bd -literal -offset indent
  632. [[endpoint]]
  633. name = "example name"
  634. url = "https://acme.example.org/directory"
  635. tos_agreed = true
  636. [[account]]
  637. name = "my test account"
  638. email = "certs@exemple.net"
  639. [[certificate]]
  640. endpoint = "example name"
  641. account = "my test account"
  642. identifiers = [
  643. { dns = "exemple.net", challenge = "http-01"},
  644. { dns = "1.exemple.net", challenge = "dns-01"},
  645. { dns = "2.exemple.net", challenge = "tls-alpn-01", env.TACD_PORT="5010"},
  646. { dns = "3.exemple.net", challenge = "tls-alpn-01", env.TACD_PORT="5011"},
  647. { ip = "203.0.113.1", challenge = "http-01"},
  648. ]
  649. hooks = ["git", "http-01-echo", "tls-alpn-01-tacd-tcp", "some-dns-01-hook"]
  650. env.HTTP_ROOT = "/srv/http"
  651. .Ed
  652. .Pp
  653. It is possible to use
  654. .Xr echo 1
  655. to solve the
  656. .Em http-01
  657. challenge and
  658. .Xr rm 1
  659. to clean it.
  660. .Xr mkdir 1
  661. and
  662. .Xr chmod 1
  663. are used to prevent issues related to file access.
  664. .Bd -literal -offset indent
  665. [[hook]]
  666. name = "http-01-echo-mkdir"
  667. type = ["challenge-http-01"]
  668. cmd = "mkdir"
  669. args = [
  670. "-m", "0755",
  671. "-p", "{{%if env.HTTP_ROOT}}{{env.HTTP_ROOT}}{{else}}/var/www{{/if}}/{{identifier}}/.well-known/acme-challenge"
  672. ]
  673. [[hook]]
  674. name = "http-01-echo-echo"
  675. type = ["challenge-http-01"]
  676. cmd = "echo"
  677. args = ["{{proof}}"]
  678. stdout = "{{%if env.HTTP_ROOT}}{{env.HTTP_ROOT}}{{else}}/var/www{{/if}}/{{identifier}}/.well-known/acme-challenge/{{file_name}}"
  679. [[hook]]
  680. name = "http-01-echo-chmod"
  681. type = ["challenge-http-01-clean"]
  682. cmd = "chmod"
  683. args = [
  684. "a+r",
  685. "{{%if env.HTTP_ROOT}}{{env.HTTP_ROOT}}{{else}}/var/www{{/if}}/{{identifier}}/.well-known/acme-challenge/{{file_name}}"
  686. ]
  687. [[hook]]
  688. name = "http-01-echo-clean"
  689. type = ["challenge-http-01-clean"]
  690. cmd = "rm"
  691. args = [
  692. "-f",
  693. "{{%if env.HTTP_ROOT}}{{env.HTTP_ROOT}}{{else}}/var/www{{/if}}/{{identifier}}/.well-known/acme-challenge/{{file_name}}"
  694. ]
  695. .Ed
  696. .Pp
  697. The hooks from the previous example can be grouped in order to reduce the number of hooks to define in the certificate.
  698. .Bd -literal -offset indent
  699. [[group]]
  700. name = "http-01-echo-var-www"
  701. hooks = [
  702. "http-01-echo-mkdir",
  703. "http-01-echo-echo",
  704. "http-01-echo-chmod",
  705. "http-01-echo-clean"
  706. ]
  707. [[certificate]]
  708. # Some fields omitted
  709. hooks = ["http-01-echo"]
  710. env.HTTP_ROOT = "/srv/http"
  711. .Ed
  712. .Pp
  713. It is also possible to use
  714. .Xr sendmail 8
  715. in a hook in order to notif someone when the certificate request process is done.
  716. .Bd -literal -offset indent
  717. [[hook]]
  718. name = "email-report"
  719. type = ["post-operation"]
  720. cmd = "sendmail"
  721. args = [
  722. "-f", "noreply.certs@example.net",
  723. "contact@example.net"
  724. ]
  725. stdin_str = """Subject: Certificate renewal {{#if is_success}}succeeded{{else}}failed{{/if}} for {{identifiers.[0]}}
  726. The following certificate has {{#unless is_success}}*not* {{/unless}}been renewed.
  727. identifiers: {{#each identifiers}}{{#if @index}}, {{/if}}{{this}}{{/each}}
  728. key type: {{key_type}}
  729. status: {{status}}"""
  730. .Ed
  731. .Sh SEE ALSO
  732. .Xr acmed 8 ,
  733. .Xr tacd 8
  734. .Sh STANDARDS
  735. .Bl
  736. .It
  737. .Rs
  738. .%A Tom Preston-Werner
  739. .%D July 2018
  740. .%T TOML v0.5.0
  741. .%U https://github.com/toml-lang/toml
  742. .Re
  743. .It
  744. .Rs
  745. .%A Yehuda Katz
  746. .%T Handlebars
  747. .%U https://handlebarsjs.com/
  748. .Re
  749. .It
  750. .Rs
  751. .%A M. Jones
  752. .%D May 2015
  753. .%R RFC 7518
  754. .%T JSON Web Algorithms (JWA)
  755. .Re
  756. .El
  757. .Sh AUTHORS
  758. .An Rodolphe Bréard
  759. .Aq rodolphe@breard.tf