cryptnox-pos 1.0.0
Standalone USDC payment terminal firmware (ESP32 + Cryptnox smart card)
Loading...
Searching...
No Matches
https_post.h File Reference

One HTTPS JSON POST, shared by every RPC client in the firmware. More...

#include <stdbool.h>
#include <stddef.h>
Include dependency graph for https_post.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool https_post_json (const char *url, const char *body, char *resp_buf, size_t resp_buf_size, const char *user, const char *pass, const char *ca_pem)
 POST a JSON body over HTTPS and read the response.

Detailed Description

One HTTPS JSON POST, shared by every RPC client in the firmware.

Moved out of eth_rpc.cpp when the Tron client arrived: the response-Date clock cross-check that defends against a spoofed SNTP clock must have a single implementation, or one endpoint ends up without it.

Definition in file https_post.h.

Function Documentation

◆ https_post_json()

bool https_post_json ( const char * url,
const char * body,
char * resp_buf,
size_t resp_buf_size,
const char * user,
const char * pass,
const char * ca_pem )

POST a JSON body over HTTPS and read the response.

The response is read until EOF or buffer-full and is always NUL-terminated. The server's Date header is cross-checked against the system clock; a parseable header that disagrees by more than five minutes fails the call (see https_post.cpp for why that is the right verdict).

Parameters
[in]urlFull HTTPS endpoint URL.
[in]bodyJSON request body (NUL-terminated).
[out]resp_bufResponse buffer, NUL-terminated on return.
[in]resp_buf_sizeCapacity of resp_buf.
[in]userHTTP Basic Auth username, or NULL/"" for none.
[in]passHTTP Basic Auth password, or NULL/"" for none.
[in]ca_pemPEM certificate to validate against instead of the Mozilla CA bundle, or NULL for the bundle.
Returns
true only if at least one byte was read AND the server answered HTTP 200; false on transport error, non-200 status or clock refusal.

Definition at line 140 of file https_post.cpp.

References clock_corroborated(), resp_hdrs_t::date, http_event_cb(), RESP_LOG_MAX, TAG, and wdt_feed().

Referenced by do_post(), and tron_post().