Brewskey / spark-protocol

Node.JS module for hosting direct encrypted CoAP socket connections
GNU Lesser General Public License v3.0
9 stars 16 forks source link

pkcs decoding error #132

Closed jinyangqiao closed 7 years ago

jinyangqiao commented 7 years ago

when I put my P1 to the local cloud,I found that the P1 can't connnect to the server,and have an error : Original error: Error: error:0407109F:rsa routines:RSA_padding_check_PKCS1_type_2:pkcs decoding error from node-rsa\src\NodeRSA.js:301:19.

PS:the code is the b971834a34ab2f67031bd0c24c851716abf77cbd

jlkalberer commented 7 years ago

How did you claim the device?

We need exact repro steps.

jinyangqiao commented 7 years ago
  1. git clone https://github.com/Brewskey/spark-server.git cd spark-server/ npm install npm run start:prod 2.particle config profile_name apiUrl "http://DOMAIN_OR_IP" 3.particle config profile_name 4.particle setup 5.create a new user 6.particle identify ,get the coreid 7.puy my P1 to DFU mode 8.particle keys server ..\spark-server\data\default_key.pub.pem IP_ADDRESS 9.particle keys doctor my_core_id

PS: The operating environment is win10

jinyangqiao commented 7 years ago

when I put my P1 to the particle cloud,it's OK! So I want to know whether the steps I claim the device is wrong or some other questions. Thank you very much!

jlkalberer commented 7 years ago

We have some extra code that makes the particle keys doctor unnecessary but I'd like to remove it. It basically adds any device to connect to the cloud without claiming it to a user.

@antonpuko this should be an easy fix and then we can remove the bandaid in cryptomanager or wherever it is.

AntonPuko commented 7 years ago

@john I made the change https://github.com/Brewskey/spark-protocol/commit/b5ede6dbaa5cc16e6f4705d2dec930aacd64d089 . it shoudn't fix the issue though. @jinyangqiao pkcs decoding error usually means that you have incorrect server key on the device. but according to your move: 8.particle keys server ..\spark-server\data\default_key.pub.pem IP_ADDRESS you should have correct one. so, it seems p1 specific, hm...

jinyangqiao commented 7 years ago

@AntonPuko ,I'm sure I have correct server key ,not only p1, my photon also have the same problem. I tested on win10 and ubuntu 16.04 ,but the problem still exists.

jlkalberer commented 7 years ago

Yeah, @AntonPuko - I think you might need to start from scratch in order to repro the bug. I've seen this happen before.

AntonPuko commented 7 years ago

Ok, turns out from some point of time we use incorrect server key size. @jinyangqiao try last dev. it should be fixed now(don't forget to remove old and recreate new server key)

jinyangqiao commented 7 years ago

OK,I tried it and ti's OK now. Thanks very much!