particle-cli icon indicating copy to clipboard operation
particle-cli copied to clipboard

Sending keys with `particle keys doctor` does not respect protocol

Open jlkalberer opened this issue 4 years ago • 0 comments

Description

When setting up a device you can pass the --protocol tcp flag to use TCP instead of UDP. This will cause the device to send RSA keys instead of ECC keys when connecting. When I call particle keys doctor it does not check what protocol the device is using. For an Electron, it always defaults to sending an ECC key.

Steps to reproduce

particle keys server default_key.pub.pem --host IP_ADDRESS --protocol tcp
particle keys doctor XXXXXXXXXXXXX

The server sees:

{ deviceID: 'XXXXXXXXXXXXX',
  publicKey:
   '-----BEGIN PUBLIC KEY-----\r\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQEq9vQ/4R01YpBjamex0slA/az72\r\nY08ngBh8BlE17S9g7GrHwQnsEjyUuBTjfjcY0P/isrBimw0gh3qiai6mRA==\r\n-----END PUBLIC KEY-----\r\n',
  order: 'manual_1589295982289',
  filename: 'cli',
  algorithm: 'ecc' }

Expected result

Since the device is in DFU mode, the CLI should first query what protocol the device is using (particle keys protocol) and use that instead of defaulting to a specific value.

Actual result

Once the device tries to connect, it sends an RSA key but the server has stored the ECC key. The device won't connect.

Environment

  • OS: All
  • Node (run node -v): v10.13.0
  • NPM (run npm -v): Yarn 1.21.1
  • Particle CLI (run particle version): 1.49.0

jlkalberer avatar May 12 '20 15:05 jlkalberer