Open aodanne opened 6 years ago
Just tested under OSX and there I do not get an ending newline. Which operating system are you testing with?
Ubuntu
I added a print of the key data read from file in dtls-client.c and tested with a key file with 9 characters under Linux Ubuntu 14.04:
> ll default-key
-rw-rw-r-- 1 user user 9 Feb 21 00:14 default-key
> ./dtls-client -k default-key 127.0.0.1
READ PSK (9 bytes): 73656372657450534b
It does not look like any newline is added for me. Could it be that your key file actually contains a newline?
If that is the case, one option would be to forbid ending whitespace in PSK and make dtls-client remove any ending whitespace when reading data from file. Since it is a test application, I do not think it would be a big limitation.
dtls-client concatenates the key from the key file (using -k) with a newline.