# Unable to secure node-red over https using self signed certs

**URL:** <https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637>\
**Category:** General\
**Created:** [7 July 2020 05:54 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637 "2020-07-07T05:54:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mannharleen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannharleen/32/25594_2.png) [@mannharleen](https://discourse.nodered.org/u/mannharleen)\
**Post date:** [7 July 2020 05:54 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/1 "2020-07-07T05:54:22Z")

</div>

I create certificates using the following commands:  
_I use **localhost** as the common-name for the second command_

```auto
openssl genrsa -out node-key.pem 2048
openssl req -new -sha256 -key node-key.pem -out node-csr.pem
openssl x509 -req -in node-csr.pem -signkey node-key.pem -out node-cert.pem

```

and modify my settings as

```auto
requireHttps: false,
    https: {
        key: fs.readFileSync('./certs/node-key.pem'),
        cert: fs.readFileSync('./certs/node-cert.pem'),
        ca: fs.readFileSync('./certs/node-csr.pem')
    },

```

I start node-red

```auto
// Create a server
let server = http.createServer(app);

// Initialise the runtime with a server and settings
RED.init(server, settings);

// Serve the editor UI from /red
app.use(settings.httpAdminRoot, RED.httpAdmin)

// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode)

server.listen(1880, async (error) => {
    // Start the runtime
    await RED.start()
})

```

Then hit the url: [https://localhost:1880/red/](https://localhost:1880/red/)  
And face the error:

```auto
ERR_SSL_PROTOCOL_ERROR

```

What am I doing wrong?

---

<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:** [7 July 2020 10:39 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/2 "2020-07-07T10:39:50Z")

</div>

Is there a reason you are trying to start Node-RED yourself rather than letting the normal startup and TLS config do the work for you?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 July 2020 10:53 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/3 "2020-07-07T10:53:34Z")

</div>

> [@mannharleen](#):
>
> `let server = http.createServer(app);`

This will be one error. You are creating an http server, not an https server.

You need to swap in the `https` module for the `http` module.

---

<div class="post-metadata">

**Author:** ![mannharleen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannharleen/32/25594_2.png) [@mannharleen](https://discourse.nodered.org/u/mannharleen)\
**Post date:** [8 July 2020 03:22 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/4 "2020-07-08T03:22:10Z")

</div>

I switched http to https (my bad!).  
And now the error is - ERR\_SSL\_VERSION\_OR\_CIPHER\_MISMATCH

---

<div class="post-metadata">

**Author:** ![mannharleen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannharleen/32/25594_2.png) [@mannharleen](https://discourse.nodered.org/u/mannharleen)\
**Post date:** [8 July 2020 03:22 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/5 "2020-07-08T03:22:50Z")

</div>

Yes. need to run it along with some other services

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [8 July 2020 06:14 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/6 "2020-07-08T06:14:59Z")

</div>

I suggest googling that error to see what it means.

For example: [https://kinsta.com/knowledgebase/err\_ssl\_version\_or\_cipher\_mismatch/](https://kinsta.com/knowledgebase/err_ssl_version_or_cipher_mismatch/)

---

<div class="post-metadata">

**Author:** ![mannharleen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannharleen/32/25594_2.png) [@mannharleen](https://discourse.nodered.org/u/mannharleen)\
**Post date:** [8 July 2020 07:04 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/7 "2020-07-08T07:04:13Z")

</div>

Will try and get back. I am surprised no one hasnt had this issue with node-red

---

<div class="post-metadata">

**Author:** ![mannharleen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mannharleen/32/25594_2.png) [@mannharleen](https://discourse.nodered.org/u/mannharleen)\
**Post date:** [8 July 2020 13:43 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/8 "2020-07-08T13:43:38Z")

</div>

Got it. Since I was using a custom express app:

```auto
let app = express();
let server = http.createServer({
    key: fs.readFileSync('./certs/node-key.pem'),
    cert: fs.readFileSync('./certs/node-cert.pem'),
    ca: fs.readFileSync('./certs/node-csr.pem')

},

```

I must include the cert info while creating the server. The following doesnt work because the server is already created by that time!

```auto
RED.init(server, settings);

```

---

<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:** [22 July 2020 13:43 UTC](https://discourse.nodered.org/t/unable-to-secure-node-red-over-https-using-self-signed-certs/29637/9 "2020-07-22T13:43:42Z")

</div>

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