I am having problems with some photons public & private key pairs. When the first batch of new photons arrived I tried to change their PKI credentials, but due to some bug with the particle cli tool it somehow corrupted the private key.
PKI/tmp# particle keys doctor 340024000547343233323032
running dfu-util -l
Found DFU device 2b04:d006
running openssl genrsa -out 340024000547343233323032_new.pem 1024
running openssl rsa -in 340024000547343233323032_new.pem -pubout -out 340024000547343233323032_new.pub.pem
running openssl rsa -in 340024000547343233323032_new.pem -outform DER -out 340024000547343233323032_new.der
New Key Created!
running dfu-util -l
Found DFU device 2b04:d006
running dfu-util -l
Found DFU device 2b04:d006
running dfu-util -d 2b04:d006 -a 1 -s 34:612 -U pre_340024000547343233323032_new.der
running openssl rsa -in pre_340024000547343233323032_new.der -inform DER -pubout -out pre_340024000547343233323032_new.pub.pem
Error saving key from device... Error: Command failed: /bin/sh -c openssl rsa -in pre_340024000547343233323032_new.der -inform DER -pubout -out pre_340024000547343233323032_new.pub.pem
unable to load Private Key
139934244984464:error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long:asn1_lib.c:157:
139934244984464:error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header:tasn_dec.c:1186:
139934244984464:error:0D06C03A:asn1 encoding routines:ASN1_D2I_EX_PRIMITIVE:nested asn1 error:tasn_dec.c:747:
139934244984464:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:666:
139934244984464:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1198:
139934244984464:error:0D06C03A:asn1 encoding routines:ASN1_D2I_EX_PRIMITIVE:nested asn1 error:tasn_dec.c:762:
139934244984464:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:694:Field=iqmp, Type=RSA
139934244984464:error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib:rsa_ameth.c:119:
139934244984464:error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1198:
139934244984464:error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:372:Type=X509_ALGOR
139934244984464:error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error:tasn_dec.c:694:Field=pkeyalg, Type=PKCS8_PRIV_KEY_INFO
Second PKI related problem is that photon-cloud connection fails with:
Handshake decryption error: [Error: error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02]
1: Core disconnected: decryption failed { coreID: 'unknown', cache_key: '_15' }
Session ended for _15
however I can’t imagine what cause this error to start popping up.
I hope there are suggestions as to how I can fix these issues since this has affected multiple photons (I thought it was the photons fault at first and tried it again with other photons, since the “key doctor” was working flawlessly on cores). Maybe a full reset of photons internal configuration (dct) table would fix this?