Https Connection to Non-tuya server
Issue Title:
Unable to Establish HTTPS Connection on Non-Tuya Server Using TuyaOS SDK
Issue Description:
I'm encountering difficulties establishing an HTTPS connection to a non-Tuya server using the TuyaOS SDK. Below are the relevant logs from my application:
Code: Select all
[01-01 00:00:04 ty D][lr:0x8146d] cache dns [REDACTED_URL]<->[REDACTED_IP]
[01-01 00:00:04 ty D][lr:0x9c779] DNS parse type:2
[01-01 00:00:04 ty D][lr:0x9c82f] bind port:0 ok
[01-01 00:00:05 ty E][lr:0x5b511] MAX SECURITY_LEVEL CONFIG ERROR: L->0,M->1
[01-01 00:00:05 ty E][lr:0x84847] tls transporter connect err:-2
[01-01 00:00:05 ty D][lr:0x84715] tls transporter close socket fd:1
[01-01 00:00:05 ty D][lr:0x9c8f5] tcp transporter close socket fd:1
[01-01 00:00:05 ty D][lr:0x8472f] tls transporter close tls handler:0x4252bc
[01-01 00:00:05 ty D][lr:0x5b827] TUYA_TLS Disconnect ENTER
[01-01 00:00:05 ty D][lr:0x5b877] TUYA_TLS Disconnect Success
[01-01 00:00:05 ty D][lr:0x76d99] Connect: [REDACTED_URL] Port: 7000 --<< ,r:-1
[01-01 00:00:05 ty D][lr:0x92cd1] Get Rssi:-63
[01-01 00:00:05 ty D][lr:0x8d8e3] url:[REDACTED_URL]
[01-01 00:00:05 ty D][lr:0x8d8f7] pstr:.[REDACTED_DOMAIN]
[01-01 00:00:05 ty D][lr:0x84715] tls transporter close socket fd:-1
[01-01 00:00:05 ty D][lr:0x84741] tls transporter already closed
[01-01 00:00:05 ty D][lr:0x5b4b3] tuya_tls_connect_destroy.
[01-01 00:00:05 ty D][lr:0x81559] lower_dns_cache_priority:0
[01-01 00:00:05 ty E][custom_http_client.c:321] Error opening HTTP session.(code: -1)
Steps to Reproduce:
Attempt to establish an HTTPS connection to a non-Tuya server using the TuyaOS SDK.
Observe the logs provided above.
Expected Behavior:
The HTTPS connection should be successfully established without errors.
Actual Behavior:
The connection attempt fails with the following error: Error opening HTTP session.(code: -1).
Environment Details:
TuyaOS SDK version: [3.9.0]
Device/Platform: [Beken7231n]
Server URL: [REDACTED_URL]
Additional Information:
I have confirmed that the server is reachable and operational as I have tested with python server.
I have verified the correctness of the server URL.
Code: Select all
tuya_tls_config_t tls_config;
tls_config.mode = TUYA_TLS_SERVER_CERT_MODE; // Example mode, adjust as needed
tls_config.hostname = host_uri;
tls_config.port = 7000; // HTTPS port
// Set CA certificate (assuming CA_CERT is defined as per your previous definitions)
tls_config.ca_cert = CA_CERT;
tls_config.ca_cert_size = strlen(CA_CERT);
// Set timeout and other parameters as needed
tls_config.timeout = 10; // Example timeout
// If you have client certificate and key, set them as follows:
tls_config.client_pkey = SSL_PRIVATE_KEY;
tls_config.client_pkey_size = strlen(SSL_PRIVATE_KEY);
/* Setup callbacks */
tls_config.f_send = send_callback;
tls_config.f_recv = recv_callback;
tls_config.exception_cb = event_callback;
// Open HTTP session with Tuya TLS configuration
int http_ret = http_open_session_with_config(&https_handle, host_uri, &tls_config, TLS_ENABLE, 0);
Proposed Solution:
Please investigate the logs provided and advise on any configuration changes or updates to the TuyaOS SDK that may be required to establish HTTPS connections to non-Tuya servers successfully and also explain what error this line is referring to specifically L->0 and M->0
Code: Select all
[01-01 00:00:05 ty E][lr:0x5b511] MAX SECURITY_LEVEL CONFIG ERROR: L->0,M->1
[01-01 00:00:05 ty E][lr:0x84847] tls transporter connect err:-2