Commit Graph
1574 Commits
Author SHA1 Message Date
Olaf Bergmann cfec0d072c configure.ac: bumped version number to 4.2.0 v4.2.0 2019-03-02 11:58:05 +01:00
Olaf Bergmann 9e365770cb client.c: updated year in runtime copyright message 2019-03-02 11:57:35 +01:00
Olaf Bergmann 2922c19970 updated copyright information
Touched dates in files where significant changes occurred in 2019.
2019-03-02 11:43:59 +01:00
Olaf Bergmann 66c682d74c Merge branch 'yr2004-patch-2' into develop 2019-03-01 16:03:36 +01:00
yr2004 e269b87151 option.c: memset the node when a new optlist node is created
memset the node when a new optlist node is created, because the node->next maybe not NULL, so if it creates a new optlist node, and delete it, and then create it again, error will be occurred
2019-03-01 16:03:00 +01:00
Olaf Bergmann da254c1f8e TODO: cleanup contents 2019-03-01 14:14:17 +01:00
Olaf Bergmann 9c939f8e9c CONTRIBUTE: nits 2019-03-01 14:14:17 +01:00
Olaf Bergmann d7e41bdc0f coap_gnutls.c: Fixed typo and updated copyright year 2019-03-01 14:13:00 +01:00
Olaf Bergmann 2de0c7d486 coap_gnutls.c: Fix out-of-bounds array access
Coverity scan found an out-of-bounds array access while reading the local array identity
(CID 1476518). This change also ensures that the result parameters are always initialized
and avoids invalid pointer dereference in case gnutls_malloc() returns NULL.
2019-03-01 14:13:00 +01:00
Olaf Bergmann 33b372d945 coap_gnutls.c: Removed dead code
Coverity found that status is always 0 when validate_cn_call_back()
is invoked (CID 1476517). This change removes the dead code by
introducing a constant that can be inferred at compile-time.
2019-03-01 14:13:00 +01:00
obgm db24e760e0 Merge pull request #304 from mrdeep1/no-ca-gnutls-3-6
Support for clients with no PKI or PSK defined for GnuTLS > 3.6 and coaps
2019-03-01 13:20:52 +01:00
Jon Shallow 3cf96472b6 Support for clients with no PKI or PSK defined for GnuTLS > 3.6 and coaps
GnuTLS 3.6.0 or later requires that gnutls_certificate_set_x509_system_trust()
is set up if PSK is not being used and PKI is not defined and the session
is to be DTLS based.

src/coap_gnutls.c:

Add in call to gnutls_certificate_set_x509_system_trust() in
setup_pki_credentials() if PKI has not been set up.
2019-03-01 11:50:38 +00:00
obgm db283b3618 Merge pull request #302 from mrdeep1/server-cleanup-on-error
GnuTLS Server: Handle session setup failures following a session setup failure
2019-03-01 12:41:07 +01:00
Jon Shallow fc7bf57a61 GnuTLS Server: Handle session setup failures following a session setup failure
src/coap_gnutls.s:

If a DTLS server session setup fails (invalid / missing certificate etc.)
and the client has sent some more of the DTLS setup exchange packets before
receiving the TLS alert packet closing things down, any subsequent new DTLS
sessions will fail.

Caused by the g_env environment getting partially polluted with information
with the subsequent DTLS setup exchange packets.

The primary fix is for coap_dtls_hello() is to clear out g_env if there is a
ClientHello packet failure (error return from do_gnutls_handshake()) as well
as if the packet is not of the form of a ClientHello, then it is simply
ignored.

(This may be what is being seen in #300)
2019-03-01 10:33:14 +00:00
obgm 9708ce172c Merge pull request #300 from mrdeep1/no-ca-etc
Support coap-client with no PKI or PSK defined, but using (D)TLS in GnuTLS
2019-02-27 09:45:21 +01:00
obgm a6d58da83f Merge pull request #301 from mrdeep1/client-fail-cleanup
coap-client: Clean exit on detection of DTLS closure
2019-02-26 21:12:31 +01:00
Jon Shallow 13f935e289 coap-client: Clean exit on detection of DTLS closure
If there is an issue during DTLS setup, the coap-client will keep on retrying
and then getting the same failure.

examples/client.c:

This fix introduces using coap events into coap-client, and on detection of
a close event, the coap-client closes down
2019-02-26 16:32:48 +00:00
Jon Shallow b74aab1971 Support coap-client with no PKI or PSK defined, but using (D)TLS in GnuTLS
To reproduce the issue:

Server session
$ coap-server -v9 -n -k secretPSK -c server.pem -C ca.pem -R /etc/ssl/certs

Client session
$ examples/coap-client -v9  coaps://127.0.0.1/

include/coap2/coap_dtls.h:
src/coap_gnutls.c:

If neither coap_new_client_session_pki() or coap_new_client_session_psk()
is called, but coap_new_client_session() is (as done by coap-client if
no PKI or PSK options set), then set up a default PKI session to be
able to talk to a coap server.
2019-02-16 20:47:13 +00:00
obgm 9ae66a66b4 Merge pull request #299 from mrdeep1/gnutls-io-error
coap-server: GnuTLS does not correctly detect closure by a client using TCP
2019-02-15 20:12:06 +01:00
obgm 4682d951fb Merge pull request #298 from mrdeep1/client-ca
coap-client: Support using CA or Root CAs, but not Cert files
2019-02-15 20:08:33 +01:00
Jon Shallow f54248d3ca coap-server: GnuTLS does not correctly detect closure by a client using TCP
To reproduce:-

Run a GnuTLS-based coap-server with option `-n` and connect with
`openssl s_client` to port 5684. The handshake works and see binary data
(the CoAP/TCP CSM signaling). Now, then interrupt the openssl s_client process
with SIGINT, This generates a lot of these messages:

Feb 14 19:22:39 DEBG ASSERT: ../../lib/record.c[_gnutls_recv_int]:1766
Feb 14 19:22:39 DEBG ASSERT: ../../lib/buffers.c[_gnutls_io_read_buffered]:589
Feb 14 19:22:39 DEBG ASSERT: ../../lib/record.c[_gnutls_recv_int]:1766
Feb 14 19:22:39 DEBG ASSERT: ../../lib/buffers.c[_gnutls_io_read_buffered]:589
Feb 14 19:22:39 DEBG ASSERT: ../../lib/record.c[_gnutls_recv_int]:1766
Feb 14 19:22:39 DEBG ASSERT: ../../lib/buffers.c[_gnutls_io_read_buffered]:589
Feb 14 19:22:39 DEBG ASSERT: ../../lib/record.c[_gnutls_recv_int]:1766
Feb 14 19:22:39 DEBG ASSERT: ../../lib/buffers.c[_gnutls_io_read_buffered]:589

An OpenSSL-based coap-server gets a clean disconnect and closes the session as
expected.

src/coap_gnutls.c:

Return correct response when coap_sock_read() is called by GnuTLS internal
Pull and the TCP session is closed so that the coap session is closed
correctly
2019-02-15 18:08:34 +00:00
Jon Shallow 829145cbba coap-client: Support using CA or Root CAs, but not Cert files
By defining the CA file or Root CAs in the client, the server's certificate
can be validated by the options in coap_dtls_pki_t parameter even if the client
does not define a certificate.
[The server must be configured not to require a Client Cert]

examples/client.c:

Add in the support to the coap-client to allow any of Root CA, CA and Cert
to be defined to set up PKI checking.

src/coap_gnutls.c:
src/coap_openssl.c:

Remove the checks in the OpenSSL and GnuTLS underlying support that previously
used to enforce that both CA and Cert had to be set in the client.

Correct some of the PKI setup error messages to relect whether the failure is
on the client or the server.

include/coap2/coap_dtls.h:
src/coap_gnutls.c:
src/coap_notls.c:
src/coap_openssl.c:
src/coap_tinydtls.c:

Convert COAP_DTLS_ROLE_SERVER and COAP_DTLS_ROLE_CLIENT to enum
coap_dtls_role_t and use as appropriate to differentiate between the roles
in the different DTLS libraries
2019-02-15 18:00:52 +00:00
Olaf Bergmann 459e43a48c coap_openssl.c: bugfix for empty PSK list
In tls_client_hello_call_back():

When SSL_client_hello_get0_ciphers() returns 0, the result parameter
out is not set. SSL_bytes_to_cipher_list() therefore is called only
if len > 0. This function's results parameters peer_ciphers and
scsvc also are accessed only if SSL_bytes_to_cipher_list() has
returned 1.

To avoid freeing invalid pointers by sk_SSL_CIPHER_free(), peer_ciphers
and scsvc have been initialized with NULL.
2019-02-14 18:51:19 +01:00
Olaf Bergmann 8dbc02d525 ChangeLog: added summary of changes in version 4.2.0 2019-02-13 10:54:51 +01:00
Carsten Schoenert aa802b3789 spelling: fix funtion -> function 2019-02-10 14:47:23 +01:00
Carsten Schoenert a54cd26c85 spelling: fix Addtional -> Additional 2019-02-10 14:47:20 +01:00
Olaf Bergmann afb0d954ed coap_gnutls.c: Fixed NULL pointer dereference
Avoid calling gnutls_transport_get_ptr() on a NULL pointer. The
crash can be reproduced by sending an invalid CA certificate.
2019-02-09 13:31:50 +01:00
obgm 7b98419dae Merge pull request #297 from mrdeep1/client-certs
coap-server: Make requirement for clients to have certificates configurable
2019-02-09 13:30:57 +01:00
Jon Shallow 037fd4395e coap-server: Make requirement for clients to have certificates configurable
Add in -n option to support making require_peer_cert configurable, by default
it is enabled unless -n is set.

examples/coap-server.c:
Code changes.

man/coap-server.txt.in
Update documentation
2019-02-07 12:03:09 +00:00
obgm 102836ce98 Merge pull request #296 from yr2004/patch-1
Update configure.ac
2019-02-04 16:53:52 +01:00
yr2004 fe92eb7d23 Update configure.ac
fix a configure.ac error for tinydtls
2019-02-02 10:33:22 +08:00
Olaf Bergmann 76daa297cd pdu.[hc]: make argument of coap_new_pdu() const
As the session object passed to coap_new_pdu() is not modified
it should be const.
2019-01-30 20:29:08 +01:00
Olaf Bergmann 48b1eff004 coap_session.[hc]: make argument of coap_session_max_pdu_size() const
As the session object passed to coap_session_max_pdu_size() is not
modified it should be const.
2019-01-30 20:27:10 +01:00
obgm 144ec406ac Merge pull request #294 from mrdeep1/identifiers
Reserved Identifier fixes
2019-01-29 17:50:00 +01:00
Jon Shallow 55d579449c Reserved Identifier fixes
include/coap2/libcoap.h
_LIBCOAP_H_ to COAP_LIBCOAP_H_
src/coap_session.c
_COAP_SESSION_H_ to COAP_SESSION_C_
include/coap2/coap_session.h
_SESSION_H_ to COAP_SESSION_H_

otherwise, all #define _COAP_xxxxx wrappers are now COAP_xxxxx

Fixes #291
2019-01-29 15:30:42 +00:00
Olaf Bergmann bcff6dec61 configure.ac: bounce version number to 4.2.0rc4 v4.2.0-rc4 2019-01-29 11:04:56 +01:00
Olaf Bergmann c0ab893666 coap-server.c: add ct to description of new resources
When a new resource is created with PUT, the given Content-Format is
stored as parameter ct with the resource description.

This change is based on a fix provided by Peter van der Stok.
2019-01-18 15:05:15 +01:00
obgm 23a01f8132 Merge pull request #289 from mrdeep1/clarify-usage-coap_add_data_blocked_response
Clarify coap_add_data_blocked_response() usage
2019-01-14 14:12:16 +01:00
Jon Shallow a6ff63b159 coap_gnutls.c: enable cipher suites required by RFC 7252
As discussed in issue #286 [1], the mandatory-to-implement
cipher suites TLS_PSK_WITH_AES_128_CCM_8 and TLS_ECDHE_ECDSA_AES_128_CCM_8
should be enabled if possible.

[1] https://github.com/obgm/libcoap/issues/286

Signed-off-by: Olaf Bergmann <bergmann@tzi.org>
2019-01-11 17:49:32 +01:00
Jon Shallow 164eef538b Clarify coap_add_data_blocked_response() usage
include/coap2/block.h
man/coap_pdu_setup.txt.in

Update documentation on coap_add_data_blocked_response() usage.
2019-01-11 16:39:02 +00:00
Olaf Bergmann 5a8c59e5aa Makefile.libcoap: rename debug.c to coap_debug.c for Contiki 2019-01-07 10:05:44 +01:00
Olaf Bergmann 29d62a2e3f examples/contiki/coap-observer.c: do not include debug.h explicitly 2019-01-07 10:04:59 +01:00
Olaf Bergmann 50c892fc81 lwip/Makefile: renamed debug.c to coap_debug.c 2019-01-07 09:56:12 +01:00
Olaf Bergmann 0388bb9e38 Renamed debug.[hc] to coap_debug.[hc]
Prefixing the file name with "coap_" helps avoiding a name clash
when libcoap is included as package in RIOT [1].

[1] https://github.com/RIOT-OS/RIOT
2019-01-07 00:51:10 +01:00
Olaf Bergmann ca1c8255a2 debug.c: Fix printf format specifiers and arguments
Version numbers in coap_tls_version_t are represented as uint64_t.
This change fixes a couple of compiler warnings raised when passing
these to %ld.
2019-01-07 00:12:58 +01:00
Olaf Bergmann 15c7f28a18 block.c: Fix printf format specifier for size_t argument 2019-01-07 00:01:40 +01:00
Olaf Bergmann 045c724ee8 address.c: [RIOT] added stub for IN_MULTICAST
On platform RIOT, the IN_MULTICAST macro is missing. This change
therefore adds a stub to prevent build errors. (WIP)
2019-01-06 23:07:07 +01:00
obgm 0b7fb3cf25 Merge pull request #285 from mrdeep1/delete_str
Remove deprecated str typedef to remove namespace pollution
2018-12-29 15:17:13 +01:00
Jon Shallow 371c295fce Remove deprecated str typedef to remove namespace pollution
As str structure has been replaced by coap_string_t, remove it from the code
as it is no longer required, has been deprecated for some time and can cause
clashes with other str definitions.

Tidy up comment referring to str.
2018-12-27 11:51:42 +00:00
Olaf Bergmann 23c60dee6f client.c: remove trailing newline from output for '-o -'
The CLI option '-o file' redirects the received payload into the
given file, where '-' denotes stdout. As the function close_output()
used to append a newline to the end of the output, certain tools
such as cbor2pretty.rb have failed, complaining about the trailing
character.

This change now writes the newline if only if option '-o' was not
specified.
2018-12-20 17:57:16 +01:00