Skip to content

Commit 3da8a23

Browse files
committed
include:update header file for root CA support
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 18eea4c commit 3da8a23

File tree

2 files changed

+25
-31
lines changed

2 files changed

+25
-31
lines changed

include/net/sockets.h

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#ifndef INCLUDE_NET_SOCKETS_H_
77
#define INCLUDE_NET_SOCKETS_H_
88

9+
#include <stdint.h>
10+
911
#ifdef __cplusplus
1012
extern "C" {
1113
#endif
@@ -42,25 +44,6 @@ enum sock_events_e {
4244
SOCK_EV_GPRS_FAILED, /**< GPRS bearer failed. */
4345
};
4446

45-
/**
46-
* SSL version
47-
*/
48-
enum ssl_ver_e {
49-
SSL_VER_DEFAULT, /**< Default SSL version (TLS 1.2) */
50-
TLS_VER_1V2 = SSL_VER_DEFAULT,/**< TLS v1.2 */
51-
TLS_VER_1V1, /**< TLS v1.1 */
52-
TLS_VER_1V0, /**< TLS v1.0 */
53-
SSL_VER_3V0, /**< SSL v3 */
54-
};
55-
56-
/**
57-
* SSL certificate input type
58-
*/
59-
enum ssl_type_e {
60-
SSL_TYPE_BUFFER,/**< certificate provided as a buffer */
61-
SSL_TYPE_FILE /**< certificate provided as a filename */
62-
};
63-
6447
/**
6548
* Socket callback structure
6649
*/
@@ -110,20 +93,20 @@ struct sockopt_t {
11093
struct ssl_sockopt_t {
11194
char server_ip[100]; /**< IP/Domain name of server */
11295
int port; /**< SSL server port */
113-
int (*status_callback)(int sockid, int status); /**< SSL socket status callback */
11496
void *arg; /**< user data to associate with socket */
97+
uint32_t timeout; /**< SSL handshake timeout in seconds, 0 for default timeout */
11598
};
11699

117100
/**
118101
* SSL client certificates
119102
*/
120103
struct ssl_certs_t {
121-
int cert_type; /**< Input type see @ref ssl_type_e */
122-
const void *cert; /**< filename/buffer containing certificate (Only PEM format supported) */
123-
int cert_len; /**< Length of certificate in case buffer is provided */
124-
int pkey_type; /**< Input type see @ref ssl_type_e */
125-
const void *privatekey; /**< filename/buffer containing private key (Only PEM format supported) */
126-
int privatekey_len; /**< Length of private key in case buffer is provided */
104+
const char *rootca; /**< buffer containing Root CA */
105+
int rootca_len; /**< Length of Root CA buffer (with null) */
106+
const char *cert; /**< buffer containing certificate */
107+
int cert_len; /**< Length of certificate buffer (with null) */
108+
const char *privatekey; /**< buffer containing private key */
109+
int privatekey_len; /**< Length of private key buffer (with null) */
127110
};
128111

129112
/* Normal Socket */
@@ -241,11 +224,10 @@ int socket_free(int id);
241224
/* SSL Sockets */
242225
/**
243226
* Request an SSL socket.
244-
* @param ssl_version [in] SSL version @ref ssl_ver_e
245227
* @param certs [in] SSL client certificate and private key. NULL if not used
246228
* @return On success SSL socket ID is returned, On error negative value is returned
247229
*/
248-
int ssl_socket_request(int ssl_version, struct ssl_certs_t *certs);
230+
int ssl_socket_request(struct ssl_certs_t *certs);
249231

250232
/**
251233
* Configure SSL socket

include/proto/httpc.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ struct http_filemeta_t {
5757
const char *mime; /**< File mime type when mime_type is set to @ref HTTP_MIME_TYPE_CUSTOM, e.g. "text/csv", NULL otherwise */
5858
};
5959

60+
/**
61+
* SSL client certificates
62+
*/
63+
struct http_certs_t {
64+
const char *rootca; /**< buffer containing Root CA */
65+
int rootca_len; /**< Length of Root CA buffer (with null) */
66+
const char *cert; /**< buffer containing certificate */
67+
int cert_len; /**< Length of certificate buffer (with null) */
68+
const char *privatekey; /**< buffer containing private key */
69+
int privatekey_len; /**< Length of private key buffer (with null) */
70+
};
71+
6072
/**
6173
* HTTP download finished callback
6274
* @param dl_size Download size
@@ -71,7 +83,7 @@ typedef void (*http_download_cb)(unsigned int dl_size, unsigned int reserved, in
7183
struct httparg_t {
7284
const char *url; /**< Client URL */
7385
const char *headers; /**< Custom headers, can be NULL. if used then header must end with CRLF (\\r\\n) */
74-
struct ssl_certs_t *certs; /**< SSL Client certificate */
86+
struct http_certs_t *certs; /**< SSL Client certificate */
7587
const void *submit_data; /**< Data to send as request body */
7688
uint16_t submit_len; /**< Length of data to send */
7789
uint8_t mime; /**< MIME type @ref http_mimetype_e */
@@ -88,7 +100,7 @@ struct httpupload_t {
88100
const char *url; /**< Client URL */
89101
const char *headers; /**< Custom headers, can be NULL. if used then header must end with CRLF (\\r\\n) */
90102
const struct http_filemeta_t *meta; /**< Upload file information @ref http_filemeta_t */
91-
const struct ssl_certs_t *certs; /**< SSL Client certificates */
103+
const struct http_certs_t *certs; /**< SSL Client certificates */
92104
int recv_headers; /**< if TRUE, HTTP response headers are also stored in response buffer */
93105
char *resp_buffer; /**< Pointer to response buffer */
94106
uint16_t buflen; /**< Length of response buffer */
@@ -103,7 +115,7 @@ struct httpdownload_t {
103115
const char *url; /**< Client URL */
104116
const char *headers; /**< Custom headers, can be NULL. if used then header must end with CRLF (\\r\\n) */
105117
const char *filepath; /**< Complete file path on storage media (255 max) */
106-
const struct ssl_certs_t *certs; /**< SSL Client certificates */
118+
const struct http_certs_t *certs; /**< SSL Client certificates */
107119
http_download_cb callback; /**< Callback function called after download is finished see @ref http_download_cb */
108120
uint16_t timeout; /**< Timeout in seconds for Read/Write in HTTP and READ in HTTPS, 0 for default 45 sec */
109121
};

0 commit comments

Comments
 (0)