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

spark keys server key.der device.bla.com does not work #145

Open
joegoggins opened this issue Feb 19, 2015 · 6 comments
Open

spark keys server key.der device.bla.com does not work #145

joegoggins opened this issue Feb 19, 2015 · 6 comments

Comments

@joegoggins
Copy link
Contributor

spark keys server key.der device.bla.com does not work correctly when using a domain name. When an IP address is specified, ala spark keys server key.der 1.2.3.4, it works fine.

The bug is likely lurking somewhere in this code.

@kennethlimcp
Copy link
Contributor

Saw a line below for checks var isIpAddress = /^[0-9.]*$/.test(ipOrDomain);

@dmiddlecamp
Copy link
Contributor

Hmm, the thing that stands out most is this (since we're not appending that odd padding byte to the string I think):

https://github.com/spark/spark-cli/blob/master/js/commands/KeyCommands.js#L367

Are you testing on an even length domain, or an odd length one?

@kennethlimcp
Copy link
Contributor

screen shot 2015-02-19 at 18 44 51

the intermediate file for mine looks fine with domain names

@joegoggins
Copy link
Contributor Author

I finally got around to analyzing this more closely. This comparison makes the issue pop out.

Last 2 lines of a working public server key for staging-device.spark.io

0000180: 0117 7374 6167 696e 672d 6465 7669 6365  ..staging-device
0000190: 2e73 7061 726b 2e69 6f00                 .spark.io.

last N lines of a non working server public key generated by the spark-cli

0000180: 0117 7374 6167 696e 672d 6465 7669 6365  ..staging-device
0000190: 2e73 7061 726b 2e69 6f00 ffff ffff ffff  .spark.io.......
00001a0: ffff ffff ffff ffff ffff ffff ffff ffff  ................
00001b0: ffff ffff ffff ffff ffff ffff ffff ffff  ................

The issue is that the generated key should end immediately after the "00" byte on line 0000190 instead of padding with fffffff until 1024 bytes is reached.

@dmiddlecamp
Copy link
Contributor

it sounds like the padding is indeed correct, but there is a missing null byte at the end of the domain string? -- Hmm, sorry, re-reading, I was comparing Kenneth's key to yours

@kennethlimcp
Copy link
Contributor

@joegoggins, the extra 00 looks suspicious after the 6f

i just generated one using a random server public der file and i got this:

0000180:  0117 7374 6167 696E 672D 6465 7669 6365 ��..staging-device
0000190:  2E73 7061 726B 2E69 6FFF FFFF FFFF FFFF .spark.io.......

I'm on version 0.4.94

and the command i used is spark keys server xxxx.der staging-device.spark.io

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

No branches or pull requests

3 participants