Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Californium DTLS failed to handshake #1668

Closed
hlkn opened this issue Nov 1, 2024 · 15 comments
Closed

Californium DTLS failed to handshake #1668

hlkn opened this issue Nov 1, 2024 · 15 comments
Labels
question Any question about leshan

Comments

@hlkn
Copy link

hlkn commented Nov 1, 2024

Question

Here is my test setup for two scenarios:

I did test for both release versions:

1.5.0 and 2.0.0-M16

And the sam result happened on both releases.

May you help if configuration to DTLS so that the BS server will not interfere with the Registration Update.

I am looking forward to hear from and Thank for your help in advanced. Henry Nguyen

  1. BS and DM application run on different servers: DID NOT work
    BS Server (bootstrap) run on bs.local=192..68.68.57/wp=8080/lp=5683/slp=5684
    BS is configured to support Id=IOTS-01 PSK=1A2B3C4D and coaps://bs.local:5684/coaps://dm.local:5684

DM server (Device Management runs on dm.local=192.168.68.58/lp=5683/slp=5684
DM is configured to support Id=IOTS-01 PSK=1A2B3C4D

DTLS for bootstrap works
DTLS for registration update failed. It the Client IOTS-01 send Client Hello but the BS sends Hello Verify to IOTS-01. The Client IOTS-01 expects the DM to send the Hello Verify.

  1. BS and DM application run on the same server: work
    BS Server (bootstrap) run on bs.local=192..68.68.57/wp=8080/lp=5683/slp=5684
    BS is configured to support Id=IOTS-01 PSK=1A2B3C4D and coaps://bs.local:6684/coaps://dm.local:6684

DM server (Device Management runs on bs.local=192.168.68.57/wp=9080/lp=6683/slp=6684
DM is configured to support Id=IOTS-01 PSK=1A2B3C4D

DTLS for bootstrap works
DTLS for registration update works. It the Client IOTS-01 send Client Hello and the DM sends Hello Verify to IOTS-01.

LeshanPoCSetup.pdf

captureinpcapngaa.zip
captureinpcapngab.zip
captureinpcapngac.zip

@hlkn hlkn added the question Any question about leshan label Nov 1, 2024
@sbernard31
Copy link
Contributor

Hi,

  1. Why using 2.0.0-M6 and not most recent one ?
  2. Which client are you using ?

I try to donwload your captures but :

  • 22 Mo for a capture about a simple use case like this ... .
  • try to open the smaller one 1.2 Mo : file in the archive has no extensions and does not work with wireshark.

Please provide more clean captures 🙏

Using same ID/PSK for bootstrap server and dm server is OK for test but not really a good idea in production.

@hlkn
Copy link
Author

hlkn commented Nov 15, 2024

Hi Leshan Gatekeepers,

  1. "Why using 2.0.0-M6 and not most recent one ?" I am using 2.0.0-M16 and I also using 1.5.0. Both releases behave the same that is DTLS shaking failed.

2 "Which client are you using?" I am using the lesion-demo-client code provided.

  1. "Using same ID/PSK for bootstrap server and dm server is OK for test but not really a good idea in production" - Thank you for remind about using different PSK ID/KEY for Production.

  2. I will provide you better Wireshark capture.

  3. Do you have a chance to look at the PDF file with few diagrams to illustrate the issue. I am sure that DTLS failed to handshake. Why? it is because if I set up both Bootstrap application and Device Management application running in the same server. Everything works fine but If I set up Bootstrap application and Device Management application the Bootstrap will interfere with the DTLS process. I will try to set up another scenarios where the PSK ID/KEY will be different for Bootstrap and Device Management if possible.

Regards, Henry

@hlkn
Copy link
Author

hlkn commented Nov 15, 2024

Hi Leshan Gatekeepers,

Here is my Wireshark file.

capturefile.pcapng.zip

Regards, Henry

PS. I used the same file but apply filter like coap port 5683 and coaps port 5684.

@sbernard31
Copy link
Contributor

Just to let you know, it is not recommended to use 2.0.0-M6 for security reason.
See : https://github.com/eclipse-leshan/leshan/security/policy#versions-security-state

As you said, the source address IP of HELLO_VERIFY_REQUEST seems not good.
You get the capture at client side right ?
My guess this is a network configuration issue and this is not related to Leshan or Scandium (the DTLS library used).

I will try to set up another scenarios where the PSK ID/KEY will be different for Bootstrap and Device Management if possible.

I doubt this will solve the issue.

Just to be sure, I tested with a leshan-client-demo 1.5.0 on Leshan sandbox and it works as expected :

❯ java -jar leshan-client-demo-1.5.0.jar  -n "IOTS-01" -i "IOTS-01" -p "1A2B3C4D" -b -u "leshan.eclipseprojects.io:5784"                                                                            

2024-11-15 11:22:53,850 INFO LeshanClientDemo - Commands available :

  - create <objectId> : to enable a new object.
  - delete <objectId> : to disable a new object.
  - update : to trigger a registration update.
  - w : to move to North.
  - a : to move to East.
  - s : to move to South.
  - d : to move to West.

2024-11-15 11:22:53,851 INFO LeshanClient - Starting Leshan client ...
2024-11-15 11:22:53,858 INFO LeshanClient - Leshan client[endpoint:IOTS-01] started.
2024-11-15 11:22:53,858 INFO DefaultRegistrationEngine - Trying to start bootstrap session to coaps://leshan.eclipseprojects.io:5784 ...
2024-11-15 11:22:54,490 INFO CaliforniumEndpointsManager - New endpoint created for server coaps://leshan.eclipseprojects.io:5784 at coaps://[0:0:0:0:0:0:0:0]:46774
2024-11-15 11:22:54,522 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : STARTED ...
2024-11-15 11:22:54,794 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : SUCCEED
2024-11-15 11:22:54,874 INFO DefaultRegistrationEngine - Bootstrap started
2024-11-15 11:22:55,077 DEBUG Security - Write on Security resource /0/0/0
2024-11-15 11:22:55,077 DEBUG Security - Write on Security resource /0/0/1
2024-11-15 11:22:55,078 DEBUG Security - Write on Security resource /0/0/2
2024-11-15 11:22:55,078 DEBUG Security - Write on Security resource /0/0/3
2024-11-15 11:22:55,078 DEBUG Security - Write on Security resource /0/0/4
2024-11-15 11:22:55,078 DEBUG Security - Write on Security resource /0/0/5
2024-11-15 11:22:55,078 DEBUG Security - Write on Security resource /0/0/6
2024-11-15 11:22:55,078 DEBUG Security - Write on Security resource /0/0/7
2024-11-15 11:22:55,078 DEBUG Security - Write on Security resource /0/0/8
2024-11-15 11:22:55,078 DEBUG Security - Write on Security resource /0/0/9
2024-11-15 11:22:55,079 DEBUG Security - Write on Security resource /0/0/11
2024-11-15 11:22:55,079 DEBUG Security - Write on Security resource /0/0/12
2024-11-15 11:22:55,157 DEBUG Security - Write on Security resource /0/1/0
2024-11-15 11:22:55,157 DEBUG Security - Write on Security resource /0/1/1
2024-11-15 11:22:55,158 DEBUG Security - Write on Security resource /0/1/2
2024-11-15 11:22:55,158 DEBUG Security - Write on Security resource /0/1/3
2024-11-15 11:22:55,158 DEBUG Security - Write on Security resource /0/1/4
2024-11-15 11:22:55,159 DEBUG Security - Write on Security resource /0/1/5
2024-11-15 11:22:55,159 DEBUG Security - Write on Security resource /0/1/6
2024-11-15 11:22:55,159 DEBUG Security - Write on Security resource /0/1/7
2024-11-15 11:22:55,160 DEBUG Security - Write on Security resource /0/1/8
2024-11-15 11:22:55,160 DEBUG Security - Write on Security resource /0/1/9
2024-11-15 11:22:55,161 DEBUG Security - Write on Security resource /0/1/10
2024-11-15 11:22:55,161 DEBUG Security - Write on Security resource /0/1/11
2024-11-15 11:22:55,161 DEBUG Security - Write on Security resource /0/1/12
2024-11-15 11:22:55,232 DEBUG Server - Write on Server resource /1/0/0
2024-11-15 11:22:55,233 DEBUG Server - Write on Server resource /1/0/1
2024-11-15 11:22:55,233 DEBUG Server - Write on Server resource /1/0/2
2024-11-15 11:22:55,234 DEBUG Server - Write on Server resource /1/0/6
2024-11-15 11:22:55,234 DEBUG Server - Write on Server resource /1/0/7
2024-11-15 11:22:55,380 INFO DefaultRegistrationEngine - Bootstrap finished coaps://leshan.eclipseprojects.io:5784.
2024-11-15 11:22:55,384 INFO CaliforniumEndpointsManager - New endpoint created for server coaps://leshan.eclipseprojects.io:5684 at coaps://[0:0:0:0:0:0:0:0]:39580
2024-11-15 11:22:55,385 INFO DefaultRegistrationEngine - Trying to register to coaps://leshan.eclipseprojects.io:5684 ...
2024-11-15 11:22:55,388 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : STARTED ...
2024-11-15 11:22:55,560 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : SUCCEED
2024-11-15 11:22:55,614 INFO DefaultRegistrationEngine - Registered with location '/rd/FudLE87GM6'.
2024-11-15 11:22:55,615 INFO DefaultRegistrationEngine - Next registration update to coaps://leshan.eclipseprojects.io:5684 in 53s...
2024-11-15 11:23:00,721 INFO LeshanClient - Destroying Leshan client ...
2024-11-15 11:23:00,722 INFO DefaultRegistrationEngine - Trying to deregister to coaps://leshan.eclipseprojects.io:5684 ...
2024-11-15 11:23:00,778 INFO DefaultRegistrationEngine - De-register response DELETED null.
2024-11-15 11:23:00,781 INFO LeshanClient - Leshan client destroyed.

@hlkn
Copy link
Author

hlkn commented Nov 17, 2024

Hi Leshan Gatekeepers,

I am not sure why you keep on saying that
"Just to let you know, it is not recommended to use 2.0.0-M6 for security reason.
See : https://github.com/eclipse-leshan/leshan/security/policy#versions-security-state"

I am using the lesion-2.0.0-M16 (M16 sixteen not M6 six).

I believe that the problem may be happening at the registration update not at the bootstrap. The client performs the bootstrap operation correctly but when the client performs registration update the DTLS fails to function because the bootstrap server interferes with the DTLS in shaking, please refer to the PDF document for the setup and Wireshark trace to see the DTLS failure.

bs.local=192.168.68.57
dm.local=192.168.68.58
iots-01=192.168.68.51

        No.     Time                            Source                                        Destination                                 Protocol Length Info

   6431 12.156966      192.168.68.51         192.168.68.57         DTLSv1.2 119    Client Hello
   6432 12.162438      192.168.68.57         192.168.68.51         DTLSv1.2 102    Hello Verify Request
   6433 12.164259      192.168.68.51         192.168.68.57         DTLSv1.2 151    Client Hello
   6434 12.165444      192.168.68.57         192.168.68.51         DTLSv1.2 162    Server Hello, Server Hello Done
   6435 12.184449      192.168.68.51         192.168.68.57         DTLSv1.2 143    Client Key Exchange, Change Cipher Spec, Finished
   6436 12.192381      192.168.68.57         192.168.68.51         DTLSv1.2 109    Change Cipher Spec, Finished
   6437 12.193665      192.168.68.51         192.168.68.57         CoAP     105    CON, MID:24550, POST, TKN:34 a4 59 57 23 19 38 d8, /bs?pct=112&ep=IOTS-01
   6438 12.195977      192.168.68.57         192.168.68.51         CoAP     83     ACK, MID:24550, 2.04 Changed, TKN:34 a4 59 57 23 19 38 d8, /bs
   6439 12.197246      192.168.68.57         192.168.68.51         CoAP     85     CON, MID:63682, DELETE, TKN:f0 a3 81 eb 66 4a 6c ad, /0
   6440 12.203849      192.168.68.51         192.168.68.57         CoAP     83     ACK, MID:63682, 2.02 Deleted, TKN:f0 a3 81 eb 66 4a 6c ad, /0
   6443 12.211932      192.168.68.57         192.168.68.51         CoAP     85     CON, MID:63683, DELETE, TKN:d8 54 cb e5 82 8e ec 58, /1
   6444 12.212601      192.168.68.51         192.168.68.57         CoAP     83     ACK, MID:63683, 2.02 Deleted, TKN:d8 54 cb e5 82 8e ec 58, /1
   6445 12.222322      192.168.68.57         192.168.68.51         CoAP     157    CON, MID:63684, PUT, TKN:14 c3 c4 fb ef 70 5c 20, /0/0
   6446 12.227191      192.168.68.51         192.168.68.57         CoAP     83     ACK, MID:63684, 2.04 Changed, TKN:14 c3 c4 fb ef 70 5c 20, /0/0
   6447 12.244935      192.168.68.57         192.168.68.51         CoAP     157    CON, MID:63685, PUT, TKN:1c e2 5a 3e 82 c8 44 cd, /0/1
   6448 12.247268      192.168.68.51         192.168.68.57         CoAP     83     ACK, MID:63685, 2.04 Changed, TKN:1c e2 5a 3e 82 c8 44 cd, /0/1
   6449 12.251552      192.168.68.57         192.168.68.51         CoAP     107    CON, MID:63686, PUT, TKN:20 98 9f 39 aa ab 2d ce, /1/0
   6450 12.252736      192.168.68.51         192.168.68.57         CoAP     83     ACK, MID:63686, 2.04 Changed, TKN:20 98 9f 39 aa ab 2d ce, /1/0
   6451 12.257932      192.168.68.57         192.168.68.51         CoAP     86     CON, MID:63687, POST, TKN:78 b3 4e 12 bc be 7e df, /bs
   6458 12.259032      192.168.68.51         192.168.68.57         CoAP     75     ACK, MID:63687, Empty Message
   6459 12.260470      192.168.68.51         192.168.68.57         CoAP     83     CON, MID:24551, 2.04 Changed, TKN:78 b3 4e 12 bc be 7e df, /bs
   6460 12.263188      192.168.68.57         192.168.68.51         CoAP     75     ACK, MID:24551, Empty Message
   6527 17.289198      192.168.68.51         192.168.68.58         DTLS     119    Client Hello
   6528 17.289770      192.168.68.57         192.168.68.51         DTLSv1.2 102    Hello Verify Request
   6551 19.295199      192.168.68.51         192.168.68.58         DTLS     119    Client Hello
   6552 19.296286      192.168.68.57         192.168.68.51         DTLSv1.2 102    Hello Verify Request

Bootstrap operation works fine

   6431 12.156966      192.168.68.51         192.168.68.57         DTLSv1.2 119    Client Hello
   6432 12.162438      192.168.68.57         192.168.68.51         DTLSv1.2 102    Hello Verify Request
   6433 12.164259      192.168.68.51         192.168.68.57         DTLSv1.2 151    Client Hello
   6434 12.165444      192.168.68.57         192.168.68.51         DTLSv1.2 162    Server Hello, Server Hello Done

After successfully bootstrap the client will perform registration update. That is when the DTLS operation fails

   6527 17.289198      192.168.68.51         192.168.68.58         DTLS     119    Client Hello
   // Client says Hello to the dm.local
   6528 17.289770      192.168.68.57         192.168.68.51         DTLSv1.2 102    Hello Verify Request
  // Bootstrap says Hello Verify Request -- It should be the DeviceManagement says Hello Verify Request
   6551 19.295199      192.168.68.51         192.168.68.58         DTLS     119    Client Hello
 // Client now says Hello to the Bootstrap
   6552 19.296286      192.168.68.57         192.168.68.51         DTLSv1.2 102    Hello Verify Request
// Bootstrap says Hello Verify Request to the Client.

I will capture the Wireshark on the client for you.

Regards, Henry

@henrynguyenattheitservice
Copy link

henrynguyenattheitservice commented Nov 18, 2024

And here I the trace for the 1.5.0 failed after bootstrap as well.
The Client ran in the Windows laptop.

C:\DevTools\Java\jdk11.0.21_9\bin\java.exe -javaagent:C:\DevTools\Jetbrains2024\idea\lib\idea_rt.jar=53904:C:\DevTools\Jetbrains2024\idea\bin -Dfile.encoding=UTF-8 -classpath C:\Users\henry\IdeaProjects\sew-poc-oma-v1.0\leshan-client-demo\target\classes;C:\Users\henry\IdeaProjects\sew-poc-oma-v1.0\leshan-client-cf\target\classes;C:\Users\henry\IdeaProjects\sew-poc-oma-v1.0\leshan-core-cf\target\classes;C:\Users\henry\IdeaProjects\sew-poc-oma-v1.0\leshan-core\target\classes;C:\Users\henry\.m2\repository\com\eclipsesource\minimal-json\minimal-json\0.9.5\minimal-json-0.9.5.jar;C:\Users\henry\IdeaProjects\sew-poc-oma-v1.0\leshan-client-core\target\classes;C:\Users\henry\.m2\repository\org\eclipse\californium\californium-core\2.8.0\californium-core-2.8.0.jar;C:\Users\henry\.m2\repository\org\eclipse\californium\californium-legal\2.8.0\californium-legal-2.8.0.jar;C:\Users\henry\.m2\repository\org\eclipse\californium\element-connector\2.8.0\element-connector-2.8.0.jar;C:\Users\henry\.m2\repository\net\i2p\crypto\eddsa\0.3.0\eddsa-0.3.0.jar;C:\Users\henry\.m2\repository\org\eclipse\californium\scandium\2.8.0\scandium-2.8.0.jar;C:\Users\henry\.m2\repository\commons-cli\commons-cli\1.5.0\commons-cli-1.5.0.jar;C:\Users\henry\.m2\repository\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;C:\Users\henry\.m2\repository\org\apache\httpcomponents\httpcore\4.3\httpcore-4.3.jar;C:\Users\henry\.m2\repository\org\apache\httpcomponents\httpclient\4.3.1\httpclient-4.3.1.jar;C:\Users\henry\.m2\repository\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;C:\Users\henry\.m2\repository\commons-codec\commons-codec\1.6\commons-codec-1.6.jar;C:\Users\henry\.m2\repository\org\slf4j\slf4j-simple\1.7.36\slf4j-simple-1.7.36.jar;C:\Users\henry\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar org.eclipse.leshan.client.demo.LeshanClientDemo -i IOTS-01 -p 1a2b3c4d -n IOTS-01 -b -u ubs.local:5684
2024-11-18 16:29:07,325 INFO LeshanClientDemo - Commands available :

  - create <objectId> : to enable a new object.
  - delete <objectId> : to disable a new object.
  - update : to trigger a registration update.
  - w : to move to North.
  - a : to move to East.
  - s : to move to South.
  - d : to move to West.

2024-11-18 16:29:07,326 INFO LeshanClient - Starting Leshan client ...
2024-11-18 16:29:07,381 INFO LeshanClient - Leshan client[endpoint:IOTS-01] started.
2024-11-18 16:29:07,381 INFO DefaultRegistrationEngine - Trying to start bootstrap session to coaps://ubs.local:5684 ...
2024-11-18 16:29:07,661 INFO CaliforniumEndpointsManager - New endpoint created for server coaps://ubs.local:5684 at coaps://0.0.0.0:54803
2024-11-18 16:29:07,705 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : STARTED ...
2024-11-18 16:29:07,872 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : SUCCEED
2024-11-18 16:29:07,911 INFO DefaultRegistrationEngine - Bootstrap started
2024-11-18 16:29:08,097 DEBUG Security - Write on Security resource /0/0/0
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/1
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/2
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/3
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/4
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/5
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/6
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/7
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/8
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/9
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/10
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/11
2024-11-18 16:29:08,098 DEBUG Security - Write on Security resource /0/0/12
2024-11-18 16:29:08,125 DEBUG Security - Write on Security resource /0/1/0
2024-11-18 16:29:08,125 DEBUG Security - Write on Security resource /0/1/1
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/2
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/3
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/4
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/5
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/6
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/7
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/8
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/9
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/10
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/11
2024-11-18 16:29:08,126 DEBUG Security - Write on Security resource /0/1/12
2024-11-18 16:29:08,138 DEBUG Server - Write on Server resource /1/0/0
2024-11-18 16:29:08,139 DEBUG Server - Write on Server resource /1/0/1
2024-11-18 16:29:08,139 DEBUG Server - Write on Server resource /1/0/2
2024-11-18 16:29:08,139 DEBUG Server - Write on Server resource /1/0/6
2024-11-18 16:29:08,139 DEBUG Server - Write on Server resource /1/0/7
2024-11-18 16:29:08,183 INFO DefaultRegistrationEngine - Bootstrap finished coaps://ubs.local:5684.
2024-11-18 16:29:08,187 INFO CaliforniumEndpointsManager - New endpoint created for server coaps://udm.local:5684 at coaps://0.0.0.0:54804
2024-11-18 16:29:08,188 INFO DefaultRegistrationEngine - Trying to register to coaps://udm.local:5684 ...
2024-11-18 16:29:08,207 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : STARTED ...
2024-11-18 16:29:39,263 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : FAILED (Handshake flight 1 failed! Stopped by timeout after 4 retransmissions!)
2024-11-18 16:29:39,267 INFO DefaultRegistrationEngine - Registration failed: Timeout.
2024-11-18 16:29:39,284 INFO CaliforniumEndpointsManager - Clear DTLS session for resumption for server coaps://udm.local:5684
2024-11-18 16:29:39,284 INFO DefaultRegistrationEngine - Trying to register to coaps://udm.local:5684 ...
2024-11-18 16:29:39,285 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : STARTED ...
2024-11-18 16:30:10,341 INFO LeshanClientDemo - DTLS Full Handshake initiated by client : FAILED (Handshake flight 1 failed! Stopped by timeout after 4 retransmissions!)
2024-11-18 16:30:10,342 INFO DefaultRegistrationEngine - Registration failed: Timeout.
2024-11-18 16:30:10,342 INFO DefaultRegistrationEngine - Try to register to coaps://udm.local:5684 again in 600s...

@sbernard31
Copy link
Contributor

sbernard31 commented Nov 18, 2024

I am using the lesion-2.0.0-M16 (M16 sixteen not M6 six).

Very sorry about that I don't know why I read M6 instead of M16 ... 🙇‍♀️

I believe that the problem may be happening at the registration update not at the bootstrap.

Probably a detail, but the device will probably do a REGISTER request, not a registration UPDATE request.
Reading your capture, I didn't see any issue in bootstrap process too.

The client performs the bootstrap operation correctly but when the client performs registration update the DTLS fails to function because the bootstrap server interferes with the DTLS in shaking, please refer to the PDF document for the setup and Wireshark trace to see the DTLS failure.

I read the PDF document twice.
I don't think the "server interfere", this sounds clearly a network issue.
Bootstrap server doesn't not send HELLO_VERIFY_REQUEST spontaneously,

I also read the capture several time and I understand the problem is the source address of HELLO_VERIFY_PACKET.

Your client logs are expected looking at wireshark capture.

So again, with current information, I see nothing which makes me think this is not a network (configuration?) issue.

Did you try to use Leshan sandbox ?

@henrynguyenattheitservice
Copy link

henrynguyenattheitservice commented Nov 19, 2024

Hi Leshan Gatekeepers,

The reason that I deploy the Bootstrap Application to run on one server and the Device Management Application to run on another server because I think in production we will deploy Leshan this way. The Bootstrap Application is used to authenticate the device. The Device Management Application is used to authorise the device.

I dont think it is because of the network issue as the Bootstrap operation works fine:

The DTLS handshake works fine
The Bootstrap operation works fine

However, when the Device performs the Registration Update

The DTLS handshake fails because I believe the DTLS logic is faultly code to use the Bootstrap server configuration. That explains why the Bootstrap Application sends the DTLS Hello Verify

I believe that the issue is likely at the Californium layer. This is because the Californium does not have information about the Device Management. It seems that the Califormum does not have to logic to support any communication to the Device Management. It can communicate to the Bootstrap Application but the Device Management Application.

And no I have not tried your sandbox yet:

https://leshan.eclipseprojects.io/
https://leshan.eclipseprojects.io/bs

All my setup is done using Jetbrains IntelliJ for both Leshan-2.0.0-M16 and Leshan-1.5.0.

All non-security work fines for both versions.
All PSK seceurity partially works, that is the bootstrap operation works well but the device registration update fails at the DTLS.

Regards, Henry

@boaks
Copy link

boaks commented Nov 19, 2024

6527 17.289198      192.168.68.51         192.168.68.58         DTLS     119    Client Hello
   // Client says Hello to the dm.local
   6528 17.289770      192.168.68.57         192.168.68.51         DTLSv1.2 102    Hello Verify Request
  // Bootstrap says Hello Verify Request -- It should be the DeviceManagement says Hello Verify Request
   6551 19.295199      192.168.68.51         192.168.68.58         DTLS     119    Client Hello
 // Client now says Hello to the Bootstrap
   6552 19.296286      192.168.68.57         192.168.68.51         DTLSv1.2 102    Hello Verify Request
// Bootstrap says Hello Verify Request to the Client.

If the Client Hello is sent to 192.168.68.58 but the Hello Verify Request is then from 192.168.68.57, you obviously have an issue with your network setup. The error is related to that, not to Californium.

BS Server (bootstrap) run on bs.local=192.168.68.57/
DM server (Device Management runs on dm.local=192.168.68.58/

Did you configure two network interfaces on the same host?
If so, you need to start the Californium connectors using the specific local addresses. There maybe more issues in your network setup, you may need to ask your network admin to help you.

@hlkn
Copy link
Author

hlkn commented Nov 20, 2024

Hi Leshan Gatekeepers,

If both the DTLS/Bootstrap and DTLS/Registration Update fail to work, then it is the network issue. But here the DTLS/Bootstrap works and DTLS/Registration Update fail. Network is an issue...Ummm I think it is the DTLS and Bootstrap/Device Management IP addresses logic may be the issue and which layer handle the swapping of the Bootstrap and Device Management IP addresses...You would know more than me.

My Bootstrap operation works fine at the DTLS handshake and Bootstrap.If it is the network issue then the DTLS handshake MUST fail at the Bootstrap operation.

6431 12.156966 192.168.68.51 192.168.68.57 DTLSv1.2 119 Client Hello
6432 12.162438 192.168.68.57 192.168.68.51 DTLSv1.2 102 Hello Verify Request
6433 12.164259 192.168.68.51 192.168.68.57 DTLSv1.2 151 Client Hello
6434 12.165444 192.168.68.57 192.168.68.51 DTLSv1.2 162 Server Hello, Server Hello Done
6435 12.184449 192.168.68.51 192.168.68.57 DTLSv1.2 143 Client Key Exchange, Change Cipher Spec, Finished
6436 12.192381 192.168.68.57 192.168.68.51 DTLSv1.2 109 Change Cipher Spec, Finished
6437 12.193665 192.168.68.51 192.168.68.57 CoAP 105 CON, MID:24550, POST, TKN:34 a4 59 57 23 19 38 d8, /bs?pct=112&ep=IOTS-01
6438 12.195977 192.168.68.57 192.168.68.51 CoAP 83 ACK, MID:24550, 2.04 Changed, TKN:34 a4 59 57 23 19 38 d8, /bs
6439 12.197246 192.168.68.57 192.168.68.51 CoAP 85 CON, MID:63682, DELETE, TKN:f0 a3 81 eb 66 4a 6c ad, /0
6440 12.203849 192.168.68.51 192.168.68.57 CoAP 83 ACK, MID:63682, 2.02 Deleted, TKN:f0 a3 81 eb 66 4a 6c ad, /0
6443 12.211932 192.168.68.57 192.168.68.51 CoAP 85 CON, MID:63683, DELETE, TKN:d8 54 cb e5 82 8e ec 58, /1
6444 12.212601 192.168.68.51 192.168.68.57 CoAP 83 ACK, MID:63683, 2.02 Deleted, TKN:d8 54 cb e5 82 8e ec 58, /1
6445 12.222322 192.168.68.57 192.168.68.51 CoAP 157 CON, MID:63684, PUT, TKN:14 c3 c4 fb ef 70 5c 20, /0/0
6446 12.227191 192.168.68.51 192.168.68.57 CoAP 83 ACK, MID:63684, 2.04 Changed, TKN:14 c3 c4 fb ef 70 5c 20, /0/0
6447 12.244935 192.168.68.57 192.168.68.51 CoAP 157 CON, MID:63685, PUT, TKN:1c e2 5a 3e 82 c8 44 cd, /0/1
6448 12.247268 192.168.68.51 192.168.68.57 CoAP 83 ACK, MID:63685, 2.04 Changed, TKN:1c e2 5a 3e 82 c8 44 cd, /0/1
6449 12.251552 192.168.68.57 192.168.68.51 CoAP 107 CON, MID:63686, PUT, TKN:20 98 9f 39 aa ab 2d ce, /1/0
6450 12.252736 192.168.68.51 192.168.68.57 CoAP 83 ACK, MID:63686, 2.04 Changed, TKN:20 98 9f 39 aa ab 2d ce, /1/0
6451 12.257932 192.168.68.57 192.168.68.51 CoAP 86 CON, MID:63687, POST, TKN:78 b3 4e 12 bc be 7e df, /bs
6458 12.259032 192.168.68.51 192.168.68.57 CoAP 75 ACK, MID:63687, Empty Message
6459 12.260470 192.168.68.51 192.168.68.57 CoAP 83 CON, MID:24551, 2.04 Changed, TKN:78 b3 4e 12 bc be 7e df, /bs
6460 12.263188 192.168.68.57 192.168.68.51 CoAP 75 ACK, MID:24551, Empty Message

After the Bootstrap operation the Device will perform Registration Update, here the DTLS handshake fails.

6527 17.289198 192.168.68.51 192.168.68.58 DTLS 119 Client Hello
// Client says Hello to the dm.local
6528 17.289770 192.168.68.57 192.168.68.51 DTLSv1.2 102 Hello Verify Request
// Bootstrap says Hello Verify Request -- It should be the DeviceManagement says Hello Verify Request
6551 19.295199 192.168.68.51 192.168.68.58 DTLS 119 Client Hello
// Client now says Hello to the Bootstrap
6552 19.296286 192.168.68.57 192.168.68.51 DTLSv1.2 102 Hello Verify Request
// Bootstrap says Hello Verify Request to the Client.

Regards, Henry

@boaks
Copy link

boaks commented Nov 20, 2024

Did you configure two network interfaces on the same host?

I may have missed it, but I can't see the answer to that question.

The handshake fails, because the Client Hello is sent to 192.168.68.58 but the Hello Verify Request as response is from 192.168.68.57. Any compliant RFC6347 implementation will fail on the address change during the handshake.

@sbernard31
Copy link
Contributor

If both the DTLS/Bootstrap and DTLS/Registration Update fail to work, then it is the network issue.

Just a detail but this is not a registration UPDATE but a REGISTER, anyway ...

My Bootstrap operation works fine at the DTLS handshake and Bootstrap.If it is the network issue then the DTLS handshake MUST fail at the Bootstrap operation.

This is not true...
We (you, boaks and me) see that the source IP Hello Verify Request is not good (expected 192.168.68.58 but was 192.168.68.57). We all agree that's why it fails.
For bootstrap, all packet are well formed so of course it works.

As boaks says :

The handshake fails, because the Client Hello is sent to 192.168.68.58 but the Hello Verify Request as response is from 192.168.68.57. Any compliant RFC6347 implementation will fail on the address change during the handshake.

So looking at received packet, we can say that at application level (Leshan/Californium/Scandium) all works as expected...

Also, it fails only in your environment. I was not able to reproduce and Leshan is largely used and nobody reports that kind of issue... (having bootstap server and DM server on different host is a very common use case)

So please stop repeat : "it works on bootstrap and not on register, so this is not a network issue"... boaks (Californium/Scandium main contributor) and me (Leshan main contributor) explain a lot why we think this is not a good argument and why there is strong hint this is a network issue.

Ummm I think it is the DTLS and Bootstrap/Device Management IP addresses logic may be the issue and which layer handle the swapping of the Bootstrap and Device Management IP addresses...You would know more than me.

I don't know what you are talking about ? you mean at client side ? The issue is not a client side as it sends packet to the right address ... I don't get your point...

If you want to move forward on this :

  1. if you don't trust us, I can understand but just try to ask to someone you trust about network question.
  2. please test with sandbox.
  3. answer to question : Did you configure two network interfaces on the same host?

@hlkn
Copy link
Author

hlkn commented Nov 21, 2024

Hi Gatekeepers,

  1. Did you configure two network interfaces on the same host? Yes I did initially. It is puzzling me a little bit here about two process runs in the memory using two seperate NICs and the DTLS Client Hello sends from the Client to the Device Management server an d the DTLS Verity Client Hello sends from the Bootstrap server.
  2. After your last discussion with you I actually separated out the Bootstrap Application to run on the first host/physical server and the Devie Management Application to run on the second host/physical server. The first Register failed with the same issue but then the next 600 sec the Device performs Bootstrap again and the Register works.

All is kind of working on separate hosts making the development environment for both Bootstrap Application and Device Management Application slightly more complex.

As for the so-called network issue. I don't know enough about it until I can debug down to the Californium to see what really happen there. You are the Gatekeepers and/or Leshan Gods live and breath every seconds.

I have my solution and we can close the issue. I move to implement the Leshan Client Demo to the Android and test out all the features like Bootstrap/Register/Register Update (my apology on this confusion) to see how Leshan Device Management handle IP Address changes together with Queue to work.

Thank for all your helping on solving the issue.

Regards, Henry Nguyễn

@hlkn hlkn closed this as completed Nov 21, 2024
@boaks
Copy link

boaks commented Nov 21, 2024

All is kind of working on separate hosts making the development environment for both Bootstrap Application and Device Management Application slightly more complex.

If you want to run that on the same host, you may be better off using different ports (different service => different port).

If two interfaces are configure, there may be more issues with that.
But one common is to open the UDP socket as "wildcard" (not bound to a specific local network interface). We have been faced similar issues with IPv6, where it's more common to have several network interfaces. To overcome that, it's required to bind the UDP socket to a specific network interface. But you need to test, if that helps. I'm, not common to leshan, so I don't know, how to start that listening on an specific local network interface. If you want just to test, if that would works, you may also use Californium/Plugtest-Server. Just run that on both network interfaces with

java -jar target/cf-plugtest-server-3.13.jar --interfaces-pattern "192.168.68.57" 
java -jar target/cf-plugtest-server-3.13.jar --interfaces-pattern "192.168.68.58" 

You will not be able to register successful, but you will see, if the dtls handshake works reliable.

@sbernard31
Copy link
Contributor

If you want to run that on the same host, you may be better off using different ports (different service => different port).

I agree with that.

Demo can easily be launch with different port :

      -lp, --coap-port=<localPort>
                        Set the local CoAP port of the Server.
                        Default: COAP_PORT value from 'Californium.properties'
                          file or 5683 if absent
      -slp, --coaps-port=<secureLocalPort>
                        Set the secure local CoAP port of the Server.
                        Default: COAP_SECURE_PORT value from 'Californium.
                          properties' file or 5684 if absent

To overcome that, it's required to bind the UDP socket to a specific network interface. ...
... I don't know, how to start that listening on an specific local network interface

 -lh, --coap-host=<localAddress>
                        Set the local CoAP address of the Server.
                        Default: any local address.
 -slh, --coaps-host=<secureLocalAddress>
                        Set the secure local CoAP address of the Server.
                        Default: any local address.

To get all arguments :

  -h, --help            Display help information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Any question about leshan
Projects
None yet
Development

No branches or pull requests

4 participants