keith-cullen / FreeCoAP

An implementation of a CoAP client, a CoAP server and a HTTP/CoAP proxy with full DTLS support.
132 stars 38 forks source link

proxy and other questions #1

Closed dodekaeder closed 7 years ago

dodekaeder commented 8 years ago

Hi.

I've Problems with the proxy test. All other tests pass 100% while proxy fails all the time. Seems to be some more general unix related problem, cause the proxy is not permitted to use the coap-client, but I don't know to solve this issue.

AND

As my first question already revealed, I'm not an expert but trying my best. To do this there would be some community very delightful. Is there any?

btw: Thx for your great work. I think CoAP is a relatively young but attractive protocol and for know I allready saw some implementations which where nice but a unix based implementaion is just awesome!

keith-cullen commented 8 years ago

Hi,

Since the proxy uses ipv6, you need to make sure that the following line appears in /etc/hosts

::1 ip6-localhost

Let me know if that works. If not, send me the output of the proxy test.

Keith.

On Mon, Mar 21, 2016 at 7:34 PM, dodekaeder notifications@github.com wrote:

Hi.

I've Problems with the proxy test. All other tests pass 100% but with proxy it fails all the time. Seems to be some more general unix related problem, cause the proxy is not permitted to use the coap-client

AND

As my first question already revealed, I'm not an expert but trying my best. To do this there would be some community very delightful. Is there any?

btw: Thx for your great work. I think CoAP is a relatively young protocol and for know I allready saw some implementations which where nice but a unix based implementaion is just awesome!

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/keith-cullen/FreeCoAP/issues/1

dodekaeder commented 8 years ago

cat of /etc/hosts

127.0.0.1        localhost
127.0.1.1        12345678-dynamicHost.nkpub.lan 12345678-dynamicHost
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

output of proxy

Notice : reading config file: 'proxy.conf'
Notice : config parameter: 'port'='12437'
Notice : config parameter: 'log_level'='debug'
Notice : config parameter: 'key_file'='server_privkey.pem'
Notice : config parameter: 'cert_file'='server_cert.pem'
Notice : config parameter: 'trust_file'='root_client_cert.pem'
Notice : config parameter: 'key_file'='client_privkey.pem'
Notice : config parameter: 'cert_file'='client_cert.pem'
Notice : config parameter: 'trust_file'='root_server_cert.pem'
Notice : finished reading config file: 'proxy.conf'
Notice : Proxy running
Notice : [0] Listening on port 12437
Notice : [0] <0> ::1 Connection started
Notice : [0] <0> ::1 Transaction started
Debug  : [0] <0> ::1 Received: GET coaps://ip6-localhost:12436/resource HTTP/1.1
Info   : [0] <0> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436
Error  : [0] <0> ::1 Failed to initialise CoAP client: Operation not permitted
Notice : [0] <0> ::1 Transaction failed
Notice : [0] <0> ::1 Connection failed
Info   : OK connections:      0
Info   : Failed connections:  1
Info   : OK transactions:     0
Info   : Failed transactions: 1
Notice : [0] <1> ::1 Connection started
Notice : [0] <1> ::1 Transaction started
Debug  : [0] <1> ::1 Received: CONNECT coaps://ip6-localhost:12436/resource HTTP/1.1
Info   : [0] <1> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436
Error  : [0] <1> ::1 Failed to initialise CoAP client: Operation not permitted
Notice : [0] <1> ::1 Transaction failed
Notice : [0] <1> ::1 Connection failed
Info   : OK connections:      0
Info   : Failed connections:  2
Info   : OK transactions:     0
Info   : Failed transactions: 2
Notice : [0] <2> ::1 Connection started
Notice : [0] <2> ::1 Transaction started
Debug  : [0] <2> ::1 Received: GET dummy://ip6-localhost:12436/resource HTTP/1.1
Info   : [0] <2> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436
Error  : [0] <2> ::1 Failed to initialise CoAP client: Operation not permitted
Notice : [0] <2> ::1 Transaction failed
Notice : [0] <2> ::1 Connection failed
Info   : OK connections:      0
Info   : Failed connections:  3
Info   : OK transactions:     0
Info   : Failed transactions: 3
Notice : [0] <3> ::1 Connection started
Notice : [0] <3> ::1 Transaction started
Debug  : [0] <3> ::1 Received: GET coaps://ip6-localhost:12436/resource HTTP/1.1
Info   : [0] <3> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436
Error  : [0] <3> ::1 Failed to initialise CoAP client: Operation not permitted
Notice : [0] <3> ::1 Transaction failed
Notice : [0] <3> ::1 Connection failed
Info   : OK connections:      0
Info   : Failed connections:  4
Info   : OK transactions:     0
Info   : Failed transactions: 4
Notice : [0] <4> ::1 Connection started
Notice : [0] <4> ::1 Transaction started
Debug  : [0] <4> ::1 Received: GET coaps://ip6-localhost:12436/unsafe HTTP/1.1
Info   : [0] <4> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436
Error  : [0] <4> ::1 Failed to initialise CoAP client: Operation not permitted
Notice : [0] <4> ::1 Transaction failed
Notice : [0] <4> ::1 Connection failed
Info   : OK connections:      0
Info   : Failed connections:  5
Info   : OK transactions:     0
Info   : Failed transactions: 5

thx in advance

keith-cullen commented 8 years ago

The problem occurs when the proxy tries to open a socket to the server. Are you running all 3 of the test_coap_server, test_proxy_http_coap and test_http_client applications?

On Tue, Mar 22, 2016 at 1:15 PM, dodekaeder notifications@github.com wrote:

output of /etc/hosts `lippe@laptop:~$ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 12345678-dynamicHost.nkpub.lan 12345678-dynamicHost The following lines are desirable for IPv6 capable hosts

::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters `

output of proxy Notice : reading config file: 'proxy.conf' Notice : config parameter: 'port'='12437' Notice : config parameter: 'log_level'='debug' Notice : config parameter: 'key_file'='server_privkey.pem' Notice : config parameter: 'cert_file'='server_cert.pem' Notice : config parameter: 'trust_file'='root_client_cert.pem' Notice : config parameter: 'key_file'='client_privkey.pem' Notice : config parameter: 'cert_file'='client_cert.pem' Notice : config parameter: 'trust_file'='root_server_cert.pem' Notice : finished reading config file: 'proxy.conf' Notice : Proxy running Notice : [0] Listening on port 12437 Notice : [0] <0> ::1 Connection started Notice : [0] <0> ::1 Transaction started Debug : [0] <0> ::1 Received: GET coaps://ip6-localhost:12436/resource HTTP/1.1 Info : [0] <0> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436 Error : [0] <0> ::1 Failed to initialise CoAP client: Operation not permitted Notice : [0] <0> ::1 Transaction failed Notice : [0] <0> ::1 Connection failed Info : OK connections: 0 Info : Failed connections: 1 Info : OK transactions: 0 Info : Failed transactions: 1 Notice : [0] <1> ::1 Connection started Notice : [0] <1> ::1 Transaction started Debug : [0] <1> ::1 Received: CONNECT coaps://ip6-localhost:12436/resource HTTP/1.1 Info : [0] <1> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436 Error : [0] <1> ::1 Failed to initialise CoAP client: Operation not permitted Notice : [0] <1> ::1 Transaction failed Notice : [0] <1> ::1 Connection failed Info : OK connections: 0 Info : Failed connections: 2 Info : OK transactions: 0 Info : Failed transactions: 2 Notice : [0] <2> ::1 Connection started Notice : [0] <2> ::1 Transaction started Debug : [0] <2> ::1 Received: GET dummy://ip6-localhost:12436/resource HTTP/1.1 Info : [0] <2> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436 Error : [0] <2> ::1 Failed to initialise CoAP client: Operation not permitted Notice : [0] <2> ::1 Transaction failed Notice : [0] <2> ::1 Connection failed Info : OK connections: 0 Info : Failed connections: 3 Info : OK transactions: 0 Info : Failed transactions: 3 Notice : [0] <3> ::1 Connection started Notice : [0] <3> ::1 Transaction started Debug : [0] <3> ::1 Received: GET coaps://ip6-localhost:12436/resource HTTP/1.1 Info : [0] <3> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436 Error : [0] <3> ::1 Failed to initialise CoAP client: Operation not permitted Notice : [0] <3> ::1 Transaction failed Notice : [0] <3> ::1 Connection failed Info : OK connections: 0 Info : Failed connections: 4 Info : OK transactions: 0 Info : Failed transactions: 4 Notice : [0] <4> ::1 Connection started Notice : [0] <4> ::1 Transaction started Debug : [0] <4> ::1 Received: GET coaps://ip6-localhost:12436/unsafe HTTP/1.1 Info : [0] <4> ::1 Connecting to CoAP server host: ip6-localhost, port: 12436 Error : [0] <4> ::1 Failed to initialise CoAP client: Operation not permitted Notice : [0] <4> ::1 Transaction failed Notice : [0] <4> ::1 Connection failed Info : OK connections: 0 Info : Failed connections: 5 Info : OK transactions: 0 Info : Failed transactions: 5

thx in advance

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/keith-cullen/FreeCoAP/issues/1#issuecomment-199808371

dodekaeder commented 8 years ago

yes I do...

output of coap server

Notice : Listening on address ::1 and port 12436

output of coap http client

----------------------------------------
test 1: Send GET request
Peer certificate validated
Info   : Sent: GET coaps://ip6-localhost:12436/resource HTTP/1.1
Content-Length: 13

Hello Server!
*****************[FAIL]*****************
test 2: Send a request with an unsupported method
Peer certificate validated
Info   : Sent: CONNECT coaps://ip6-localhost:12436/resource HTTP/1.1
Content-Length: 13

Hello Server!
*****************[FAIL]*****************
test 3: Send a request with an unsupported scheme in the request-URI
Peer certificate validated
Info   : Sent: GET dummy://ip6-localhost:12436/resource HTTP/1.1
Content-Length: 13

Hello Server!
*****************[FAIL]*****************
test 4: Send a request with an unsupported Accept header value
Peer certificate validated
Info   : Sent: GET coaps://ip6-localhost:12436/resource HTTP/1.1
Accept: unsupported/format
Content-Length: 13

Hello Server!
*****************[FAIL]*****************
test 5: Send a request that will invoke a response from the CoAP server with an unsafe option
Peer certificate validated
Info   : Sent: GET coaps://ip6-localhost:12436/unsafe HTTP/1.1
Content-Length: 13

Hello Server!
*****************[FAIL]*****************

[Total: 5, Pass: 0, Fail: 5]
dodekaeder commented 8 years ago

Just to understand.

The proxy calls the client. The clients output is the only one I can't see in this test but it works like in the other tests, right?

My Unix imagination just reaches the possibility of a system task which isn't authorized by the owner, like starting the client.

keith-cullen commented 8 years ago

You should check which one of the return statements is being executed in the coap_client_dtls_create. One of them is returning -1. This corresponds to the 'Operation not permitted' error message.

On Tue, Mar 22, 2016 at 1:42 PM, dodekaeder notifications@github.com wrote:

Just to understand.

The proxy calls the client. The clients output is the only one I can't see in this test but it works like in the other test, right?

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/keith-cullen/FreeCoAP/issues/1#issuecomment-199820868

keith-cullen commented 7 years ago

The URI module used by the HTTP/CoAP proxy now supports IPv6 addresses, e.g. coaps://[::1]:12436/resource