1c87c5fbaSopenharmony_ci// -*- mode:doc; -*-
2c87c5fbaSopenharmony_ci// vim: set syntax=asciidoc tw=0
3c87c5fbaSopenharmony_ci
4c87c5fbaSopenharmony_cicoap-server(5)
5c87c5fbaSopenharmony_ci==============
6c87c5fbaSopenharmony_ci:doctype: manpage
7c87c5fbaSopenharmony_ci:man source:   coap-server
8c87c5fbaSopenharmony_ci:man version:  @PACKAGE_VERSION@
9c87c5fbaSopenharmony_ci:man manual:   coap-server Manual
10c87c5fbaSopenharmony_ci
11c87c5fbaSopenharmony_ciNAME
12c87c5fbaSopenharmony_ci-----
13c87c5fbaSopenharmony_cicoap-server,
14c87c5fbaSopenharmony_cicoap-server-gnutls,
15c87c5fbaSopenharmony_cicoap-server-mbedtls,
16c87c5fbaSopenharmony_cicoap-server-openssl,
17c87c5fbaSopenharmony_cicoap-server-notls
18c87c5fbaSopenharmony_ci- CoAP Server based on libcoap
19c87c5fbaSopenharmony_ci
20c87c5fbaSopenharmony_ciSYNOPSIS
21c87c5fbaSopenharmony_ci--------
22c87c5fbaSopenharmony_ci*coap-server* [*-d* max] [*-e*] [*-g* group] [*-l* loss] [*-p* port] [*-r*]
23c87c5fbaSopenharmony_ci              [*-t*]  [*-v* num] [*-w* [port][,secure_port]]
24c87c5fbaSopenharmony_ci              [*-A* address] [*-E* oscore_conf_file[,seq_file]]
25c87c5fbaSopenharmony_ci              [*-G* group_if] [*-L* value] [*-N*]
26c87c5fbaSopenharmony_ci              [*-P* scheme://addr[:port],[name1[,name2..]]]
27c87c5fbaSopenharmony_ci              [*-T* max_token_size] [*-U* type] [*-V* num] [*-X* size]
28c87c5fbaSopenharmony_ci              [[*-h* hint] [*-i* match_identity_file] [*-k* key]
29c87c5fbaSopenharmony_ci              [*-s* match_psk_sni_file] [*-u* user]]
30c87c5fbaSopenharmony_ci              [[*-c* certfile] [*-j* keyfile] [*-n*] [*-C* cafile]
31c87c5fbaSopenharmony_ci              [*-J* pkcs11_pin] [*-M* rpk_file] [*-R* trust_casfile]
32c87c5fbaSopenharmony_ci              [*-S* match_pki_sni_file]]
33c87c5fbaSopenharmony_ci
34c87c5fbaSopenharmony_ciFor *coap-server* versions that use libcoap compiled for different
35c87c5fbaSopenharmony_ci(D)TLS libraries, *coap-server-notls*, *coap-server-gnutls*,
36c87c5fbaSopenharmony_ci*coap-server-openssl*, *coap-server-mbedtls* or *coap-server-tinydtls* may be
37c87c5fbaSopenharmony_ciavailable.  Otherwise, *coap-server* uses the default libcoap (D)TLS support.
38c87c5fbaSopenharmony_ci
39c87c5fbaSopenharmony_ciDESCRIPTION
40c87c5fbaSopenharmony_ci-----------
41c87c5fbaSopenharmony_ci*coap-server* is an example server for the 'Constrained Application Protocol`
42c87c5fbaSopenharmony_ci(RFC 7252).
43c87c5fbaSopenharmony_ci
44c87c5fbaSopenharmony_ciOPTIONS - General
45c87c5fbaSopenharmony_ci-----------------
46c87c5fbaSopenharmony_ci*-d* max::
47c87c5fbaSopenharmony_ci   Enable support for creation of dynamic resources when doing a PUT up to a
48c87c5fbaSopenharmony_ci   limit of 'max'.  If 'max' is reached, a 4.06 code is returned until one of
49c87c5fbaSopenharmony_ci   the dynamic resources has been deleted.
50c87c5fbaSopenharmony_ci
51c87c5fbaSopenharmony_ci*-e* ::
52c87c5fbaSopenharmony_ci   Echo back the data sent with a PUT.
53c87c5fbaSopenharmony_ci
54c87c5fbaSopenharmony_ci*-g* group::
55c87c5fbaSopenharmony_ci   Join specified multicast 'group' on start up.
56c87c5fbaSopenharmony_ci   *Note:* DTLS over multicast is not currently supported.
57c87c5fbaSopenharmony_ci
58c87c5fbaSopenharmony_ci*-l* list::
59c87c5fbaSopenharmony_ci   Fail to send some datagrams specified by a comma separated list of
60c87c5fbaSopenharmony_ci   numbers or number ranges (debugging only).
61c87c5fbaSopenharmony_ci
62c87c5fbaSopenharmony_ci*-l* loss%::
63c87c5fbaSopenharmony_ci   Randomly failed to send datagrams with the specified probability - 100%
64c87c5fbaSopenharmony_ci   all datagrams, 0% no datagrams (debugging only).
65c87c5fbaSopenharmony_ci
66c87c5fbaSopenharmony_ci*-p* port::
67c87c5fbaSopenharmony_ci   The 'port' on the given address will be listening for incoming connections.
68c87c5fbaSopenharmony_ci   If (D)TLS is supported, then 'port' + 1 will also be listened on for
69c87c5fbaSopenharmony_ci   (D)TLS connections.
70c87c5fbaSopenharmony_ci   The default port is 5683 if not given any other value.
71c87c5fbaSopenharmony_ci
72c87c5fbaSopenharmony_ci*-r* ::
73c87c5fbaSopenharmony_ci   Enable multicast per resource support.  If enabled, only '/', '/async'
74c87c5fbaSopenharmony_ci   and '/.well-known/core' are enabled for multicast requests support,
75c87c5fbaSopenharmony_ci   otherwise all resources are enabled.
76c87c5fbaSopenharmony_ci
77c87c5fbaSopenharmony_ci*-t* ::
78c87c5fbaSopenharmony_ci   Track resource's observe values so observe subscriptions can be
79c87c5fbaSopenharmony_ci   maintained over a server restart.
80c87c5fbaSopenharmony_ci   Note: Use 'kill SIGUSR2 <pid>' for controlled shutdown.
81c87c5fbaSopenharmony_ci
82c87c5fbaSopenharmony_ci*-v* num::
83c87c5fbaSopenharmony_ci   The verbosity level to use (default 4, maximum is 8) for general
84c87c5fbaSopenharmony_ci   CoAP logging.
85c87c5fbaSopenharmony_ci
86c87c5fbaSopenharmony_ci*-w* [port][,secure_port]::
87c87c5fbaSopenharmony_ci   Enable WebSockets support support on port (WS) and/or secure_port (WSS),
88c87c5fbaSopenharmony_ci   comma separated.
89c87c5fbaSopenharmony_ci
90c87c5fbaSopenharmony_ci*-A* address::
91c87c5fbaSopenharmony_ci   The local address of the interface which the server has to listen on.
92c87c5fbaSopenharmony_ci
93c87c5fbaSopenharmony_ci*-E* oscore_conf_file[,seq_file]::
94c87c5fbaSopenharmony_ci   'oscore_conf_file' contains OSCORE configuration. See *coap-oscore-conf*(5)
95c87c5fbaSopenharmony_ci   for definitions. Optional 'seq_file' (which is created if needed) is used to
96c87c5fbaSopenharmony_ci   save the current transmit sequence number, so on server restart sequence
97c87c5fbaSopenharmony_ci   numbers continue to increase and are not reset to prevent anti-replay
98c87c5fbaSopenharmony_ci   mechanisms being triggered.
99c87c5fbaSopenharmony_ci
100c87c5fbaSopenharmony_ci*-G* group_if::
101c87c5fbaSopenharmony_ci   Use this interface for listening for the multicast group. This can be
102c87c5fbaSopenharmony_ci   different from the implied interface if the *-A* option is used.
103c87c5fbaSopenharmony_ci
104c87c5fbaSopenharmony_ci*-L* value::
105c87c5fbaSopenharmony_ci   Sum of one or more COAP_BLOCK_* flag values for different block handling
106c87c5fbaSopenharmony_ci   methods. Default is 1 (COAP_BLOCK_USE_LIBCOAP).
107c87c5fbaSopenharmony_ci
108c87c5fbaSopenharmony_ci     COAP_BLOCK_USE_LIBCOAP  1
109c87c5fbaSopenharmony_ci     COAP_BLOCK_SINGLE_BODY  2
110c87c5fbaSopenharmony_ci     COAP_BLOCK_TRY_Q_BLOCK  4
111c87c5fbaSopenharmony_ci
112c87c5fbaSopenharmony_ci*-N* ::
113c87c5fbaSopenharmony_ci   Send NON-confirmable message for "observe" responses. If option *-N* is
114c87c5fbaSopenharmony_ci   not specified, a confirmable response will be sent.  Even if set, every
115c87c5fbaSopenharmony_ci   fifth response will still be sent as a confirmable response
116c87c5fbaSopenharmony_ci   (RFC 7641 requirement).
117c87c5fbaSopenharmony_ci
118c87c5fbaSopenharmony_ci*-P* scheme://address[:port],[name1[,name2[,name3..]]] ::
119c87c5fbaSopenharmony_ci   Scheme, address, optional port of how to connect to the next proxy server
120c87c5fbaSopenharmony_ci   and zero or more names (comma separated) that this proxy server is known by.
121c87c5fbaSopenharmony_ci   The , (comma) is required.  If there is no name1 or
122c87c5fbaSopenharmony_ci   if the hostname of the incoming proxy request matches one of these names,
123c87c5fbaSopenharmony_ci   then this server is considered to be the final endpoint. If
124c87c5fbaSopenharmony_ci   scheme://address[:port] is not defined before the leading , (comma) of the
125c87c5fbaSopenharmony_ci   first name, then the ongoing connection will be a direct connection.
126c87c5fbaSopenharmony_ci   Scheme is one of coap, coaps, coap+tcp and coaps+tcp.
127c87c5fbaSopenharmony_ci
128c87c5fbaSopenharmony_ci*-T* max_token_size::
129c87c5fbaSopenharmony_ci   Set the maximum token length (8-65804).
130c87c5fbaSopenharmony_ci
131c87c5fbaSopenharmony_ci*-U* type::
132c87c5fbaSopenharmony_ci   Treat address defined by *-A* as a Unix socket address.
133c87c5fbaSopenharmony_ci   Type is 'coap' (using datagram), 'coap+tcp' (using stream), 'coaps'
134c87c5fbaSopenharmony_ci   (DTLS using datagram) or 'coaps+tcp' (TLS using stream).
135c87c5fbaSopenharmony_ci
136c87c5fbaSopenharmony_ci*-V* num::
137c87c5fbaSopenharmony_ci   The verbosity level to use (default 3, maximum is 7) for (D)TLS
138c87c5fbaSopenharmony_ci   library logging.
139c87c5fbaSopenharmony_ci
140c87c5fbaSopenharmony_ci*-X* size::
141c87c5fbaSopenharmony_ci   Maximum message size to use for TCP based connections (default is 8388864).
142c87c5fbaSopenharmony_ci   Maximum value of 2^32 -1.
143c87c5fbaSopenharmony_ci
144c87c5fbaSopenharmony_ciOPTIONS - PSK
145c87c5fbaSopenharmony_ci-------------
146c87c5fbaSopenharmony_ci(If supported by underlying (D)TLS library)
147c87c5fbaSopenharmony_ci
148c87c5fbaSopenharmony_ci*-h* hint::
149c87c5fbaSopenharmony_ci   Identity Hint to send. Default is *CoAP*. Zero length is no hint.
150c87c5fbaSopenharmony_ci
151c87c5fbaSopenharmony_ci*-i* match_identiity_file::
152c87c5fbaSopenharmony_ci   This is a file that contains one or more lines of Identity Hints and (user)
153c87c5fbaSopenharmony_ci   Identities to match for a different new Pre-Shared Key (PSK) (comma
154c87c5fbaSopenharmony_ci   separated) to be used. E.g., per line +
155c87c5fbaSopenharmony_ci   hint_to_match,identity_to_match,use_key +
156c87c5fbaSopenharmony_ci   A line that starts with # is treated as a comment. +
157c87c5fbaSopenharmony_ci   Note: *-k* still needs to be defined for the default case. +
158c87c5fbaSopenharmony_ci   Note: A match using the *-s* option may mean that the current Identity Hint
159c87c5fbaSopenharmony_ci   is different to that defined by *-h*.
160c87c5fbaSopenharmony_ci
161c87c5fbaSopenharmony_ci*-k* key::
162c87c5fbaSopenharmony_ci   Pre-shared key to use for inbound connections. This cannot be empty if
163c87c5fbaSopenharmony_ci   defined. +
164c87c5fbaSopenharmony_ci   Note: if *-c cafile* is defined, you need to define *-k key* as well to
165c87c5fbaSopenharmony_ci   have the server support both PSK and PKI.
166c87c5fbaSopenharmony_ci
167c87c5fbaSopenharmony_ci*-s* match_psk_sni_file::
168c87c5fbaSopenharmony_ci   This is a file that contains one or more lines of received Subject Name
169c87c5fbaSopenharmony_ci   Identifier (SNI) to match to use a different Identity Hint and associated
170c87c5fbaSopenharmony_ci   Pre-Shared Key (PSK) (comma separated) instead of the *-h hint* and
171c87c5fbaSopenharmony_ci   *-k key* options. E.g., per line +
172c87c5fbaSopenharmony_ci   sni_to_match,use_hint,with_key +
173c87c5fbaSopenharmony_ci   Note: *-k key* still needs to be defined for the default case if there is
174c87c5fbaSopenharmony_ci   not a match. +
175c87c5fbaSopenharmony_ci   Note: The associated Pre-Shared Key will get updated if there is also a *-i*
176c87c5fbaSopenharmony_ci   match. The update checking order is *-s* followed by *-i*.
177c87c5fbaSopenharmony_ci
178c87c5fbaSopenharmony_ci*-u* user ::
179c87c5fbaSopenharmony_ci   User identity for pre-shared key mode (only used if option *-P* is set).
180c87c5fbaSopenharmony_ci
181c87c5fbaSopenharmony_ciOPTIONS - PKI
182c87c5fbaSopenharmony_ci-------------
183c87c5fbaSopenharmony_ci(If supported by underlying (D)TLS library)
184c87c5fbaSopenharmony_ci
185c87c5fbaSopenharmony_ci*Note:* If any one of *certfile*, *keyfile* or *cafile* is in PKCS11 URI
186c87c5fbaSopenharmony_cinaming format (pkcs11: prefix), then any remaining non PKCS11 URI file
187c87c5fbaSopenharmony_cidefinitions have to be in DER, not PEM, format.  Otherwise all of
188c87c5fbaSopenharmony_ci*certfile*, *keyfile* or *cafile* are in PEM format.
189c87c5fbaSopenharmony_ci
190c87c5fbaSopenharmony_ci*-c* certfile::
191c87c5fbaSopenharmony_ci  PEM file or PKCS11 URI for the certificate. The private key can also be in
192c87c5fbaSopenharmony_ci  the PEM file, or has the same PKCS11 URI. If not, the private key is defined
193c87c5fbaSopenharmony_ci  by *-j keyfile*. +
194c87c5fbaSopenharmony_ci  Note: if *-k key* is defined, you need to define *-c certfile* as well to
195c87c5fbaSopenharmony_ci  have the server support both PSK and PKI.
196c87c5fbaSopenharmony_ci
197c87c5fbaSopenharmony_ci*-j* keyfile::
198c87c5fbaSopenharmony_ci  PEM file or PKCS11 URI for the private key for the certificate in *-c
199c87c5fbaSopenharmony_ci  certfile* if the parameter is different from certfile in *-c certfile*.
200c87c5fbaSopenharmony_ci
201c87c5fbaSopenharmony_ci*-n* ::
202c87c5fbaSopenharmony_ci  Disable remote peer certificate checking. This gives clients the ability to
203c87c5fbaSopenharmony_ci  use PKI, but without any defined certificates.
204c87c5fbaSopenharmony_ci
205c87c5fbaSopenharmony_ci*-C* cafile::
206c87c5fbaSopenharmony_ci  PEM file or PKCS11 URI that contains a list of one or more CAs that are to
207c87c5fbaSopenharmony_ci  be passed to the client for the client to determine what client certificate
208c87c5fbaSopenharmony_ci  to use.  Normally, this list of CAs would be the root CA and and any
209c87c5fbaSopenharmony_ci  intermediate CAs. Ideally the server certificate should be signed by the
210c87c5fbaSopenharmony_ci  same CA so that mutual authentication can take place. The contents of
211c87c5fbaSopenharmony_ci  *cafile* are added to the trusted store of root CAs.  Using the *-C* or *-R*
212c87c5fbaSopenharmony_ci  options will will trigger the validation of the client certificate unless
213c87c5fbaSopenharmony_ci  overridden by the *-n* option.
214c87c5fbaSopenharmony_ci
215c87c5fbaSopenharmony_ci*-J* pkcs11_pin::
216c87c5fbaSopenharmony_ci   The user pin to unlock access to the PKCS11 token.
217c87c5fbaSopenharmony_ci
218c87c5fbaSopenharmony_ci*-M*::
219c87c5fbaSopenharmony_ci  Raw Public Key (RPK) PEM file or PKCS11 URI that contains both PUBLIC KEY
220c87c5fbaSopenharmony_ci  and PRIVATE KEY or just EC PRIVATE KEY. (GnuTLS and TinyDTLS(PEM) support
221c87c5fbaSopenharmony_ci  only).  *-C cafile* or *-R trust_casfile* are not required.
222c87c5fbaSopenharmony_ci
223c87c5fbaSopenharmony_ci*-R* trust_casfile::
224c87c5fbaSopenharmony_ci  PEM file containing the set of trusted root CAs that are to be used to
225c87c5fbaSopenharmony_ci  validate the client certificate. Alternatively, this can point to a
226c87c5fbaSopenharmony_ci  directory containing a set of CA PEM files. The *-C cafile* CA does not have
227c87c5fbaSopenharmony_ci  to be in this list and is trusted for the validation. Using
228c87c5fbaSopenharmony_ci  *-R trust_casfile* disables common CA mutual authentication which can only
229c87c5fbaSopenharmony_ci  be done by using *-C cafile*. Using the *-C* or *-R* options will will
230c87c5fbaSopenharmony_ci  trigger the validation of the server certificate unless overridden by the
231c87c5fbaSopenharmony_ci  *-n* option.
232c87c5fbaSopenharmony_ci
233c87c5fbaSopenharmony_ci*-S* match_pki_sni_file::
234c87c5fbaSopenharmony_ci   This option denotes a file that contains one or more lines of Subject Name
235c87c5fbaSopenharmony_ci   Identifier (SNI) to match for new certificate File and new CA File (comma
236c87c5fbaSopenharmony_ci   separated) to be used. E.g., entry per line +
237c87c5fbaSopenharmony_ci   sni_to_match,new_cert_file,new_ca_file +
238c87c5fbaSopenharmony_ci   A line that starts with # is treated as a comment. +
239c87c5fbaSopenharmony_ci   Note: *-c certfile* and *-C cafile* still needs to be defined for the
240c87c5fbaSopenharmony_ci   default case
241c87c5fbaSopenharmony_ci
242c87c5fbaSopenharmony_ciEXAMPLES
243c87c5fbaSopenharmony_ci--------
244c87c5fbaSopenharmony_ci* Example
245c87c5fbaSopenharmony_ci----
246c87c5fbaSopenharmony_cicoap-server -A ::1
247c87c5fbaSopenharmony_ci----
248c87c5fbaSopenharmony_ciLet the server listen on localhost (port '5683') for UDP/TCP.
249c87c5fbaSopenharmony_ci
250c87c5fbaSopenharmony_ci* Example
251c87c5fbaSopenharmony_ci----
252c87c5fbaSopenharmony_cicoap-server -A ::1 -k mysecretKey -h myhint
253c87c5fbaSopenharmony_ci----
254c87c5fbaSopenharmony_ciLet the server listen on localhost (port '5683' for UDP/TCP and port '5684' for
255c87c5fbaSopenharmony_ciDTLS/TLS) with the server set up for PSK authentication if the client uses
256c87c5fbaSopenharmony_cicoaps:// or coaps+tcp://.
257c87c5fbaSopenharmony_ci
258c87c5fbaSopenharmony_ci* Example
259c87c5fbaSopenharmony_ci----
260c87c5fbaSopenharmony_cicoap-server -A ::1 -k mysecretKey -h myhint -p 13011
261c87c5fbaSopenharmony_ci----
262c87c5fbaSopenharmony_ciThe same, except the UDP/TCP listening port is '13011' and the DTLS/TLS
263c87c5fbaSopenharmony_cilistening port is '13012' (and not the default ports '5683' and '5684').
264c87c5fbaSopenharmony_ci
265c87c5fbaSopenharmony_ci* Example
266c87c5fbaSopenharmony_ci----
267c87c5fbaSopenharmony_cicoap-server -A 2001:db8:81a8:0:6ef0:dead:feed:beef -v 5
268c87c5fbaSopenharmony_ci----
269c87c5fbaSopenharmony_ciThe listening address is set to '2001:db8:81a8:0:6ef0:dead:feed:beef' and the
270c87c5fbaSopenharmony_civerbosity level is set to '5'.
271c87c5fbaSopenharmony_ci
272c87c5fbaSopenharmony_ci* Example
273c87c5fbaSopenharmony_ci----
274c87c5fbaSopenharmony_cicoap-server -A 2001:db8:81a8:0:6ef0:dead:feed:beef -g FF02::FD
275c87c5fbaSopenharmony_ci----
276c87c5fbaSopenharmony_ciSet listening address to '2001:db8:81a8:0:6ef0:dead:feed:beef' and join the
277c87c5fbaSopenharmony_ciAll CoAP Nodes multicast group 'FF02::FD'.
278c87c5fbaSopenharmony_ci
279c87c5fbaSopenharmony_ciFILES
280c87c5fbaSopenharmony_ci------
281c87c5fbaSopenharmony_ciThere are no configuration files.
282c87c5fbaSopenharmony_ci
283c87c5fbaSopenharmony_ciEXIT STATUS
284c87c5fbaSopenharmony_ci-----------
285c87c5fbaSopenharmony_ci*0*::
286c87c5fbaSopenharmony_ci   Success
287c87c5fbaSopenharmony_ci
288c87c5fbaSopenharmony_ci*1*::
289c87c5fbaSopenharmony_ci   Failure (syntax or usage error; configuration error; document
290c87c5fbaSopenharmony_ci   processing failure; unexpected error)
291c87c5fbaSopenharmony_ci
292c87c5fbaSopenharmony_ciSEE ALSO
293c87c5fbaSopenharmony_ci--------
294c87c5fbaSopenharmony_ci
295c87c5fbaSopenharmony_ci*coap-client*(5) and *coap-oscore-conf*(5)
296c87c5fbaSopenharmony_ci
297c87c5fbaSopenharmony_ciBUGS
298c87c5fbaSopenharmony_ci-----
299c87c5fbaSopenharmony_ciPlease report bugs on the mailing list for libcoap:
300c87c5fbaSopenharmony_cilibcoap-developers@lists.sourceforge.net or raise an issue on GitHub at
301c87c5fbaSopenharmony_cihttps://github.com/obgm/libcoap/issues
302c87c5fbaSopenharmony_ci
303c87c5fbaSopenharmony_ciAUTHORS
304c87c5fbaSopenharmony_ci-------
305c87c5fbaSopenharmony_ciThe libcoap project <libcoap-developers@lists.sourceforge.net>
306