# Enable HTTPS with Wildcard SSL Certificate

**URL:** <https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999>\
**Category:** General\
**Created:** [8 February 2022 17:08 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999 "2022-02-08T17:08:22Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayson](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jayson](https://discourse.nodered.org/u/jayson)\
**Post date:** [8 February 2022 17:08 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/1 "2022-02-08T17:08:22Z")

</div>

Hi All,

I want to enable the https of Node-red but my tech only provided me a wildcard ssl and only 1 pem key. based on the documentation, I need the Private and Cert Chain in PEM key. How can I use this one?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 February 2022 17:36 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/2 "2022-02-08T17:36:37Z")

</div>

Are you saying that they only provided a single file?

You need a public key file and a private certificate file - these HAVE to be separate in use.

Maybe they are expecting you to generate a key file?

I'm not certain as I've not done it, but I think you can generate the public key using this command:

```auto
openssl x509 -pubkey -noout -in cert.pem > pubkey.pem

```

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [8 February 2022 19:41 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/3 "2022-02-08T19:41:59Z")

</div>

To add to the possibilities here.  
you can also use a certificate/key exchange file (as I do)

```auto
https: {
     pfx: require('fs').readFileSync('~/certs/certificate.p12'),
     passphrase: 'some-password'
}

```

---

<div class="post-metadata">

**Author:** ![jayson](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jayson](https://discourse.nodered.org/u/jayson)\
**Post date:** [9 February 2022 16:23 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/4 "2022-02-09T16:23:08Z")

</div>

I tried both of your suggestion but it didn't worked. Here's my code...

```auto
  requireHttps: true,
  https: {
    key: require("fs").readFileSync('C:/Users/wshostak/.node-red/certs/e2private.pem'),
    cert: require("fs").readFileSync('C:/Users/wshostak/.node-red/certs/pubkey.pem')
  }
  // https: {
  // pfx: require('fs').readFileSync('C:/Users/wshostak/.node-red/certs/e2ccwildcard.pfx'),
  // passphrase: "password here."
  // }

```

---

<div class="post-metadata">

**Author:** ![jayson](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jayson](https://discourse.nodered.org/u/jayson)\
**Post date:** [9 February 2022 16:23 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/5 "2022-02-09T16:23:38Z")

</div>

@marcus-j-davies @TotallyInformation

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [9 February 2022 16:29 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/6 "2022-02-09T16:29:54Z")

</div>

> [@jayson](#):
>
> but it didn't worked

Did you see any errors when you restarted node-red ?

At the top of your NR `settings.js` file .. did you uncomment `fs` ??

```auto
// The `https` setting requires the `fs` module. Uncomment the following
// to make it available:
var fs = require("fs");

```

---

<div class="post-metadata">

**Author:** ![jayson](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jayson](https://discourse.nodered.org/u/jayson)\
**Post date:** [9 February 2022 16:39 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/7 "2022-02-09T16:39:58Z")

</div>

> [@UnborN](#):
>
> `var fs = require("fs");`

I only have this code:

```auto
  functionGlobalContext: {
    fs: require('fs'),
    luxon: require('luxon-business-days')
  },

```

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [9 February 2022 16:43 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/8 "2022-02-09T16:43:58Z")

</div>

> [@jayson](#):
>
> `functionGlobalContext`

those are settings for Function nodes to be able to use modules

> [@UnborN](#):
>
> At the top of your NR `settings.js` file .. did you uncomment `fs` ??

At the **top** of settings.js you have to uncomment `var fs = require("fs");`  
so the settings.js file can require fs and read the private and public keys

---

<div class="post-metadata">

**Author:** ![jayson](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jayson](https://discourse.nodered.org/u/jayson)\
**Post date:** [9 February 2022 17:00 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/9 "2022-02-09T17:00:30Z")

</div>

> [@UnborN](#):
>
> var fs = require("fs");

Actually I dont have that variable declaration at all. I tried adding it but still didn't work

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [9 February 2022 17:13 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/10 "2022-02-09T17:13:48Z")

</div>

I think It might be worth ruling out Node Red its self - although I cant imagine why it would have problems

Here is a self signed cert.  
Use it as follows

```javascript
 https: {
    key: require("fs").readFileSync('C:/Users/wshostak/.node-red/certs/26599750_node-red.key.txt'),
    cert: require("fs").readFileSync('C:/Users/wshostak/.node-red/certs/26599750_node-red.cert.txt')
  }

```

If this works, then I think there might be something up with with the certificate you have maybe 🤷‍♂️

[26599750\_node-red.key.txt](https://discourse.nodered.org/uploads/short-url/l1luVWCcPkKRLY35xC8AOwocAMl.txt) (1.6 KB)  
[26599750\_node-red.cert.txt](https://discourse.nodered.org/uploads/short-url/17uw5foPbkTxv1EZL92OqUPujmJ.txt) (1013 Bytes)

Also note: that Node RED secures port 1880 - so you will need.  
**https://...:1880** not **https://...:443** \<-- default for SSL. at least that is what happens to me.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [9 February 2022 17:19 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/11 "2022-02-09T17:19:43Z")

</div>

> [@jayson](#):
>
> Actually I dont have that variable declaration at all.

I must have been using an older settings.js file that had the require of fs at the top  
apologies .. i later noticed that with `require("fs").readFileSync`  
fs was required and used on the same code line .. doh

---

<div class="post-metadata">

**Author:** ![jayson](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jayson](https://discourse.nodered.org/u/jayson)\
**Post date:** [9 February 2022 17:39 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/12 "2022-02-09T17:39:10Z")

</div>

It's working now! I'm having error because I'm not using the 1880 port. Thaaaaaanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 February 2022 17:39 UTC](https://discourse.nodered.org/t/enable-https-with-wildcard-ssl-certificate/57999/13 "2022-02-23T17:39:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
