Search code examples
c#coap

Coap Server Unauthorized Access C#


I am trying o figure out how CoAP server handles authentication. DTLS seems to be the only option. However I could not find any clear example of it for .NET. I have also seen a mention about cookie on server side but that is all, no more information.

https://github.com/chkr1011/CoAPnet seems to be a good library. They also have a client example but I sould not find server example of it. Projest seems to have CoAP server as well, however I could not find it in source code.

Can any client send requests to the server if url is known? Is DTLS the way to go? Is there any server/client example of DTLS in C#?


Solution

  • If a java server will also help, have a look at eclipse/californium. We run a sondbox at "californium.eclipse.org" and if you want to "connect" a client, you may just use the "openssl" PSK demo credentials "Client_identity" and "secretPSK".

    Can any client send requests to the server if url is known?

    That depends on the protocol variant. Without encryption (plain coap), yes. Some projects then use a "token" in the request, to authenticate the request (see ThingsBoard). With encryption (DTLS, coaps), you need valid credentials, e.g. PSK (as above), a x.509 certificate or a Raw Public Key certificate. There are also setups, where only the server authenticates itself using x.509, and the client then uses the already encrpyted communication to authenticate with an other mechanism (e.g. username/password, so very similar to the model, mostly used with https).

    The most pain is usually to find implementations, which could be used in the intended/wanted way. Maybe some projects helps you, to adapt the implementation.

    Is DTLS the way to go?

    In my opinion, yes. The alternative with OSCORE (payload encryption) are currently in development, we will see, if that changes the game.

    Is there any server/client example of DTLS in C#?

    I don't know that. Maybe you ask that the project you already found. Or ask here CoAP-CSharp