Lines Matching refs:ssl

20 #define GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t)         \  argument
21 transport_esp_tls_t *ssl = ssl_get_context_data(t); \
22 if (!ssl) { return; }
55 transport_esp_tls_t *ssl = esp_transport_esp_tls_create(); in ssl_get_context_data() local
56 ESP_TRANSPORT_MEM_CHECK(TAG, ssl, return NULL) in ssl_get_context_data()
57 t->data = ssl; in ssl_get_context_data()
58 return ssl; in ssl_get_context_data()
63 transport_esp_tls_t *ssl = ssl_get_context_data(t); in esp_tls_connect_async() local
64 if (ssl->conn_state == TRANS_SSL_INIT) { in esp_tls_connect_async()
65 ssl->cfg.timeout_ms = timeout_ms; in esp_tls_connect_async()
66 ssl->cfg.is_plain_tcp = is_plain_tcp; in esp_tls_connect_async()
67 ssl->cfg.non_block = true; in esp_tls_connect_async()
68 ssl->ssl_initialized = true; in esp_tls_connect_async()
69 ssl->tls = esp_tls_init(); in esp_tls_connect_async()
70 if (!ssl->tls) { in esp_tls_connect_async()
73 ssl->conn_state = TRANS_SSL_CONNECTING; in esp_tls_connect_async()
74 ssl->sockfd = INVALID_SOCKET; in esp_tls_connect_async()
76 if (ssl->conn_state == TRANS_SSL_CONNECTING) { in esp_tls_connect_async()
77 int progress = esp_tls_conn_new_async(host, strlen(host), port, &ssl->cfg, ssl->tls); in esp_tls_connect_async()
79 ssl->sockfd = ssl->tls->sockfd; in esp_tls_connect_async()
99 transport_esp_tls_t *ssl = ssl_get_context_data(t); in ssl_connect() local
101 ssl->cfg.timeout_ms = timeout_ms; in ssl_connect()
102 ssl->cfg.is_plain_tcp = false; in ssl_connect()
104 ssl->ssl_initialized = true; in ssl_connect()
105 ssl->tls = esp_tls_init(); in ssl_connect()
106 if (ssl->tls == NULL) { in ssl_connect()
111 if (esp_tls_conn_new_sync(host, strlen(host), port, &ssl->cfg, ssl->tls) <= 0) { in ssl_connect()
113 esp_transport_set_errors(t, ssl->tls->error_handle); in ssl_connect()
114 esp_tls_conn_destroy(ssl->tls); in ssl_connect()
115 ssl->tls = NULL; in ssl_connect()
116 ssl->sockfd = INVALID_SOCKET; in ssl_connect()
119 ssl->sockfd = ssl->tls->sockfd; in ssl_connect()
125 transport_esp_tls_t *ssl = ssl_get_context_data(t); in tcp_connect() local
128 ssl->cfg.timeout_ms = timeout_ms; in tcp_connect()
129 …esp_err_t err = esp_tls_plain_tcp_connect(host, strlen(host), port, &ssl->cfg, err_handle, &ssl->s… in tcp_connect()
133 ssl->sockfd = INVALID_SOCKET; in tcp_connect()
141 transport_esp_tls_t *ssl = ssl_get_context_data(t); in base_poll_read() local
149 FD_SET(ssl->sockfd, &readset); in base_poll_read()
150 FD_SET(ssl->sockfd, &errset); in base_poll_read()
152 if (ssl->tls && (remain = esp_tls_get_bytes_avail(ssl->tls)) > 0) { in base_poll_read()
156 …ret = select(ssl->sockfd + 1, &readset, NULL, &errset, esp_transport_utils_ms_to_timeval(timeout_m… in base_poll_read()
157 if (ret > 0 && FD_ISSET(ssl->sockfd, &errset)) { in base_poll_read()
160 getsockopt(ssl->sockfd, SOL_SOCKET, SO_ERROR, &sock_errno, &optlen); in base_poll_read()
162 …, "poll_read select error %d, errno = %s, fd = %d", sock_errno, strerror(sock_errno), ssl->sockfd); in base_poll_read()
170 transport_esp_tls_t *ssl = ssl_get_context_data(t); in base_poll_write() local
177 FD_SET(ssl->sockfd, &writeset); in base_poll_write()
178 FD_SET(ssl->sockfd, &errset); in base_poll_write()
179 …ret = select(ssl->sockfd + 1, NULL, &writeset, &errset, esp_transport_utils_ms_to_timeval(timeout_… in base_poll_write()
180 if (ret > 0 && FD_ISSET(ssl->sockfd, &errset)) { in base_poll_write()
183 getsockopt(ssl->sockfd, SOL_SOCKET, SO_ERROR, &sock_errno, &optlen); in base_poll_write()
185 … "poll_write select error %d, errno = %s, fd = %d", sock_errno, strerror(sock_errno), ssl->sockfd); in base_poll_write()
194 transport_esp_tls_t *ssl = ssl_get_context_data(t); in ssl_write() local
197 …ESP_LOGW(TAG, "Poll timeout or error, errno=%s, fd=%d, timeout_ms=%d", strerror(errno), ssl->sockf… in ssl_write()
200 int ret = esp_tls_conn_write(ssl->tls, (const unsigned char *) buffer, len); in ssl_write()
203 esp_transport_set_errors(t, ssl->tls->error_handle); in ssl_write()
211 transport_esp_tls_t *ssl = ssl_get_context_data(t); in tcp_write() local
214 …ESP_LOGW(TAG, "Poll timeout or error, errno=%s, fd=%d, timeout_ms=%d", strerror(errno), ssl->sockf… in tcp_write()
217 int ret = send(ssl->sockfd,(const unsigned char *) buffer, len, 0); in tcp_write()
228 transport_esp_tls_t *ssl = ssl_get_context_data(t); in ssl_read() local
233 int ret = esp_tls_conn_read(ssl->tls, (unsigned char *)buffer, len); in ssl_read()
236 esp_transport_set_errors(t, ssl->tls->error_handle); in ssl_read()
251 transport_esp_tls_t *ssl = ssl_get_context_data(t); in tcp_read() local
256 int ret = recv(ssl->sockfd, (unsigned char *)buffer, len, 0); in tcp_read()
274 transport_esp_tls_t *ssl = ssl_get_context_data(t); in base_close() local
275 if (ssl && ssl->ssl_initialized) { in base_close()
276 ret = esp_tls_conn_destroy(ssl->tls); in base_close()
277 ssl->tls = NULL; in base_close()
278 ssl->conn_state = TRANS_SSL_INIT; in base_close()
279 ssl->ssl_initialized = false; in base_close()
280 ssl->sockfd = INVALID_SOCKET; in base_close()
281 } else if (ssl && ssl->sockfd >= 0) { in base_close()
282 ret = close(ssl->sockfd); in base_close()
283 ssl->sockfd = INVALID_SOCKET; in base_close()
290 transport_esp_tls_t *ssl = ssl_get_context_data(t); in base_destroy() local
291 if (ssl) { in base_destroy()
306 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_enable_global_ca_store()
307 ssl->cfg.use_global_ca_store = true; in esp_transport_ssl_enable_global_ca_store()
313 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_psk_key_hint()
314 ssl->cfg.psk_hint_key = psk_hint_key; in esp_transport_ssl_set_psk_key_hint()
320 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_cert_data()
321 ssl->cfg.cacert_pem_buf = (void *)data; in esp_transport_ssl_set_cert_data()
322 ssl->cfg.cacert_pem_bytes = len + 1; in esp_transport_ssl_set_cert_data()
327 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_cert_data_der()
328 ssl->cfg.cacert_buf = (void *)data; in esp_transport_ssl_set_cert_data_der()
329 ssl->cfg.cacert_bytes = len; in esp_transport_ssl_set_cert_data_der()
334 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_client_cert_data()
335 ssl->cfg.clientcert_pem_buf = (void *)data; in esp_transport_ssl_set_client_cert_data()
336 ssl->cfg.clientcert_pem_bytes = len + 1; in esp_transport_ssl_set_client_cert_data()
341 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_client_cert_data_der()
342 ssl->cfg.clientcert_buf = (void *)data; in esp_transport_ssl_set_client_cert_data_der()
343 ssl->cfg.clientcert_bytes = len; in esp_transport_ssl_set_client_cert_data_der()
348 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_client_key_data()
349 ssl->cfg.clientkey_pem_buf = (void *)data; in esp_transport_ssl_set_client_key_data()
350 ssl->cfg.clientkey_pem_bytes = len + 1; in esp_transport_ssl_set_client_key_data()
355 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_client_key_password()
356 ssl->cfg.clientkey_password = (void *)password; in esp_transport_ssl_set_client_key_password()
357 ssl->cfg.clientkey_password_len = password_len; in esp_transport_ssl_set_client_key_password()
362 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_client_key_data_der()
363 ssl->cfg.clientkey_buf = (void *)data; in esp_transport_ssl_set_client_key_data_der()
364 ssl->cfg.clientkey_bytes = len; in esp_transport_ssl_set_client_key_data_der()
370 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_alpn_protocol()
371 ssl->cfg.alpn_protos = alpn_protos; in esp_transport_ssl_set_alpn_protocol()
377 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_skip_common_name_check()
378 ssl->cfg.skip_common_name = true; in esp_transport_ssl_skip_common_name_check()
384 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_use_secure_element()
385 ssl->cfg.use_secure_element = true; in esp_transport_ssl_use_secure_element()
392 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_crt_bundle_attach()
393 ssl->cfg.crt_bundle_attach = crt_bundle_attach; in esp_transport_ssl_crt_bundle_attach()
409 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_ds_data()
410 ssl->cfg.ds_data = ds_data; in esp_transport_ssl_set_ds_data()
416 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_keep_alive()
417 ssl->cfg.keep_alive_cfg = (tls_keep_alive_cfg_t *) keep_alive_cfg; in esp_transport_ssl_set_keep_alive()
422 GET_SSL_FROM_TRANSPORT_OR_RETURN(ssl, t); in esp_transport_ssl_set_interface_name()
423 ssl->cfg.if_name = if_name; in esp_transport_ssl_set_interface_name()