TLS Key for Local Server Can't Be Converted to DER format

I have been attempting to connect an Electron to the a local Particle Cloud, following this guide: https://docs.particle.io/support/troubleshooting/cloud-solutions/electron/#building-a-local-cloud-for-devices

I was able to get to step six, however when I ran the “particle keys server default_key.pub.pem IP_ADDRESS” command, i got “5052:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:Expecting: TRUSTED CERTIFICATE

I did swap out the IP_ADDRESS with the proper IP. Is there anything that I need to do to make the command work? Is there a modification that I need to make to the .pem file in order to make it work?

Even if that step succeeded, I’m not convinced the local cloud server does support Electrons.
@bryce, any info on that?

And even if, on what network have you got the server running?
What IP are you passing (private, public, static, dynamic)?
If it’s in your own network, have you set all the required ports to be forwarded to the local server?

The only way you could connect an Electron to the local cloud server is if you switch it to TCP mode (it is UDP by default). You can do so with the particle keys protocol tcp command. To flash the server key for TCP mode, use particle keys server public_key.der IP_ADDRESS --protocol tcp. See https://github.com/spark/particle-cli#particle-keys-server for more information.

I’ve not tested the local server with an Electron, so it may still not work properly. The local cloud server does not support UDP mode at this time.

1 Like

The IP that I am passing the Electron is a public IP. As for the key, is there any way to fix the default_key.pub.pem so that it will convert to a DER key on windows? If not so, is there another key that I should be using instead?

After running @bryce’s suggested command, this was the output:

After running particle keys address, it returned tcp://$id.udp.particle.io:5683. How do I get the address to change?

You still need to run particle keys protocol tcp to switch protocols. You flashed a new TCP key, but that doesn’t automatically switch protocols.

@bryce is currently using the TCP protocol, however the address has not changed. It is using tcp://$id.udp.particle.io:5683 whenever I run the particle keys address command.

This looks like a bug in the CLI where it isn’t reading the correct key based on the protocol selected. See https://github.com/spark/particle-cli/issues/280

Based on the command output from earlier, it should have the correct address. Are you able to establish a connection?

@bryce It looks more like it is having trouble changing the IP. It was not able to establish the connection when I tested it and it still gives the same response afterward. Please do note that the protocol section of the response to particle keys address is tcp://. It is specifically the IP address and the port number that are not correct. Is there some way to force the Electron to use the Alternate Setting #1?

@bryce Here is the output of the server after I have followed this guide, along with your suggestions, for trying to connect the Electron to the local cloud:

It says Core, but all I have attempting to connect to it is the Electron.