Local cloud & SSL (https)

hi everyone, is there a way to set up a local cloud with SSL?

for example, instead of:

http://cloud.local:8080/v1/devices/[coreid]/someVar?access_token=[accesstoken]

i can tap into my local cloud as:

https://cloud.local/v1/devices/[coreid]/someVar?access_token=[accesstoken]

i cannot figure out how to go about doing this. my local cloud on a rpi otherwise works well.

1 Like

Hi @chuank,

Good question! Checkout this line of code in the spark-server:

http://docs.spark.io/webhooks/#webhook-options-mydevices

Just update that to use node’s built in https instead, docs here:

https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener

Thanks,
David

2 Likes

Thanks @Dave, much appreciated!

1 Like

Hi Dave,
Can you repost your first link? I can’t find the line that you are referring to.
Thanks!

Hi @skyw33,

Weird that the link isn’t there anymore, I think it was something like…

Thanks,
David

Thank you @Dave! I was able to get https working with curl on my local server. I now have what I think is a related issue. When I use the command

particle flash [device_id] firmware.bin

I get the error

flash device got error: {“code”:“DEPTH_ZERO_SELF_SIGNED_CERT”}

I think it might be related to certificates that need to be applied to particle-cli in the same way that I applied them to spark-server, but I can’t figure out what I should change. Do you have any suggestions?
Thanks again!

Hi @skyw33,

Sounds like the certificate you’re using wasn’t signed by a certificate authority, so the CLI can’t tell if its genuine or not. You can modify the CLI and tell it you don’t care about the authenticity of the certificate by adding a param to the request:

// in lib/ApiClient.js

	//PUT /v1/devices/{DEVICE_ID}
	flashDevice: function (coreID, files) {
		console.log('attempting to flash firmware to your device ' + coreID);

		var that = this;
		var dfd = when.defer();
		var r = request.put(this.baseUrl + '/v1/devices/' + coreID + '?access_token=' + this._access_token, {
			json: true,
                        // add this line: will tell it to ignore a bad certificate -- don't forget the comma above!
                        rejectUnauthorized: false
		},

Thanks,
David

1 Like

@Dave – Brilliant!!! Worked like a charm :smile:

1 Like