# Curl to HTTP Request, msg.rejectUnauthorized

**URL:** https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828
**Category:** General
**Created:** [30 April 2025 12:18 UTC](https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828 "2025-04-30T12:18:17Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)
#### Post date: [30 April 2025 12:18 UTC](https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828/1 "2025-04-30T12:18:17Z")

</div>

Hi,

I am having a problem converting a Curl command to an HTTP Request on a Teltonika Router.

Hoping there is enough information here!

The Curl command is:-

`curl -X POST "https://<ROUTERIP>/api/login" -H "Content-Type: application/json" -d `{"username": "<username>", "password": "<password>"}` -k`

With a Verbose response of:-

```auto
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying v:443...
* Connected to <ROUTERIP> (<ROUTERIP>) port 443
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_CHACHA20_POLY1305_SHA256 / X25519 / id-ecPublicKey
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
* subject: C=LT; ST=Vilnius; L=Vilnius; O=Teltonika9c3e02a3; CN=Teltonika
* start date: Mar 6 15:28:50 2025 GMT
* expire date: Mar 4 15:28:50 2035 GMT
* issuer: CN=ca
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Certificate level 0: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using sha256WithRSAEncryption
* using HTTP/1.x
> POST /api/login HTTP/1.1
> Host: <ROUTERIP>
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 67
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/1.1 200 OK
< Connection: close
< Transfer-Encoding: chunked
< Expect-CT: max-age=86400
< Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Content-Security-Policy: default-src 'self'; frame-src * 'self'; img-src * 'self' data: blob:; script-src 'wasm-unsafe-eval' https://cdn.jsdelivr.net/ 'sha256-LV+4Blj3LIWsLHvvq37tdHwBQpq6ZOI+wHw3XeGsJzM=' 'self' 'sha256-8yE2w7Bv8/Il8SvtEkB35j3QNRei9CKtdX8HgqblU04=' 'sha256-Pv4HyWUIdh/mQalp8JMzRdM1eTkfzYhRRnW/9m4pzQ8=' 'sha256-/83V68bpILlL4sGTUJ9oviiw3La/Bskmmf83WaWOw9I=' blob:; style-src https://cdn.jsdelivr.net/ 'unsafe-hashes' 'sha256-4Su6mBWzEIFnH4pAGMOuaeBrstwJN4Z3pq/s1Kn4/KQ=' 'sha256-kwpt3lQZ21rs4cld7/uEm9qI5yAbjYzx+9FGm/XmwNU=' 'self'; connect-src 'self'; worker-src 'self' blob:; child-src 'self' blob:; 
< Cache-Control: no-cache
< Access-Control-Allow-Origin: *
< Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
< Content-Type: application/json
< 
* Closing connection
* TLSv1.3 (OUT), TLS alert, close notify (256):
{"success":true,"data":{"username":"admin","token":"<TOKEN>","expires":299}}

```

Trying to use the HTTP Request node, I get an `UNABLE_TO_VERIFY_LEAF_SIGNATURE` when injecting just the Payload (User/password).

In the Curl Command, I see `SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.` to overcome this I added `msg.rejectUnauthorized = false` in the Inject node. Now the I see `requesting`, and then after a time the HTTP Request node shows `no response from server`.

Flow

```auto
[{"id":"ef778648825337cb","type":"inject","z":"c17afc2be7cc5e34","name":"Payload and Reject Unauth","props":[{"p":"payload"},{"p":"rejectUnauthorized","v":"false","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":"6","topic":"","payload":"{\"username\":\"<USERNAME\",\"password\":\"PASSWORD\"}","payloadType":"json","x":210,"y":260,"wires":[["38de799b1b6912aa","39e747f0b6789e32"]]},{"id":"38de799b1b6912aa","type":"http request","z":"c17afc2be7cc5e34","name":"fetch Token","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://<ROUTERIP>/api/login","tls":"","persist":true,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""},{"keyType":"other","keyValue":"Authorization","valueType":"other","valueValue":"Bearer <AUTH_TOKEN>"},{"keyType":"other","keyValue":"Content-length","valueType":"other","valueValue":"67"}],"x":490,"y":260,"wires":[["8e8e7e27668c91f3"]]},{"id":"8e8e7e27668c91f3","type":"debug","z":"c17afc2be7cc5e34","name":"Token","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":260,"wires":[]},{"id":"39e747f0b6789e32","type":"debug","z":"c17afc2be7cc5e34","name":"Inputs","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":300,"wires":[]},{"id":"72444f26261e574c","type":"inject","z":"c17afc2be7cc5e34","name":"Just Payload","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"6","topic":"","payload":"{\"username\":\"<USERNAME\",\"password\":\"PASSWORD\"}","payloadType":"json","x":170,"y":300,"wires":[["39e747f0b6789e32","38de799b1b6912aa"]]}]

```

Tried all sorts of things and now I class myself as 'Officially Stuck', not sure where to turn next!

Any help would be gratefully received.  
TIA

Best wishes,  
Colin J

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [30 April 2025 13:59 UTC](https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828/2 "2025-04-30T13:59:19Z")

</div>

In your curl statement, you are using `-k`, which tells it to ignore certificate issues. for JS, set an environment variable which does the same::

```auto
set NODE_TLS_REJECT_UNAUTHORIZED=0

```

or, within a function node:

```auto
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

```

---

<div class="post-metadata">

### Author: ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)
#### Post date: [30 April 2025 14:17 UTC](https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828/3 "2025-04-30T14:17:14Z")

</div>

> [@omrid](#):
>
> `process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"`

~~Thank you for that, I can feel my headache lifting!!~~

Never having set an Environmental Variable before ~~I now need to understand what I have just done! (Will my headache come back?? 🤣)~~

Sorry, so excited I was reading the output of my Catch NODE. Teach me not to properly label Debug nodes!!

Need to look into this further as operation has completely changed. I need to debug flow a bit further,

---

<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: [30 April 2025 15:03 UTC](https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828/4 "2025-04-30T15:03:43Z")

</div>

I see in your flow you have as the url

```auto
http://<ROUTERIP>/api/login

```

Have you tried `https` instead of `http` ?  
In the Teltonika API docs it says

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c2179d6699a5b89c0cbece5053669ce608b0f16e.png)

Source  
[https://developers.teltonika-networks.com/](https://developers.teltonika-networks.com/)

---

<div class="post-metadata">

### Author: ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)
#### Post date: [30 April 2025 15:10 UTC](https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828/5 "2025-04-30T15:10:05Z")

</div>

> [@UnborN](#):
>
> `http://<ROUTERIP>/api/login`

Ah, apologies again. That was my sanitised flow, in the actual flow it is https. I must have copied that node when I was getting desperate to get it working and tried lots of different stuff in my fumblings around.

Flow amended.

---

<div class="post-metadata">

### Author: ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)
#### Post date: [30 April 2025 15:38 UTC](https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828/6 "2025-04-30T15:38:55Z")

</div>

I have carried on and using the search `process.env.NODE_TLS_REJECT_UNAUTHORIZED =` from @omrid answer, I found this thread

> [@Disable SSL certificate verification](https://discourse.nodered.org/t/disable-ssl-certificate-verification/88195/3):
>
> Hi Knolleary unfortunately doesnt work. I still have no response from the request

I imported this into my flow and modified my HTTP request to the same as the 'Self Signed' HTTP Request node in this flow. It didn't work.

Copied the 'Self Signed' HTTP Request and inserted in place of my node and it worked. I have now studied both my original node with that from the other thread and can find no differences. I have no idea why it wouldn't work.

Funnily enough, one of my 'fumblings' yesterday was to create a TLS check as @knolleary had indicated (without seeing his post). So I am please I was on the right track.

Thank you @omrid and @UnborN for your pointers! I couldn't have done it without your help!!

---

<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: [14 May 2025 15:39 UTC](https://discourse.nodered.org/t/curl-to-http-request-msg-rejectunauthorized/96828/7 "2025-05-14T15:39:24Z")

</div>

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