完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用arduino ide开发esp23-CAM,其CPU为esp32-s2,利用http协议将图片传给百度智能云,但我发现不能实现网页证书的鉴定,即使我已经下载了证书并嵌入代码,而且还不能跳过,因为跳过的配置需要在esp-idf,我认为这种设计极为不便,希望有技术支持?以下是部分代码 const char* root_ca ="-----BEGIN CERtiFICATE-----n""MIIJ6DCCCNCgAwIBAgIMVeasrtH4pDD5qTjFMA0GCSqGSIb3DQEBCwUAMFAxCzAJn""BgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMSYwJAYDVQQDEx1Hn""bG9iYWxTaWduIFJTQSBPViBTU0wgQ0EgMjAxODAeFw0yMzA3MDYwMTUxMDZaFw0yn""NDA4MDYwMTUxMDVaMIGAMQswCQYDVQQGEwJDTjEQMA4GA1UECBMHYmVpamluZzEQn""MA4GA1UEBxMHYmVpamluZzE5MDcGA1UEChMwQmVpamluZyBCYWlkdSBOZXRjb20gn""U2NpZW5jZSBUZWNobm9sb2d5IENvLiwgTHRkMRIwEAYDVQQDEwliYWlkdS5jb20wn""ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC7BLuEdlgHtFqIVOBqVrzln""1I0+Hrko4NcBjzgrQbJZffCsJ7QmJBQ4/kzqO0lR9+lbQPc/psjaDwJuJYtHkbgun""ngAhGR0YAPzeBP0meTld8pC8gJ2ofLKRiYnYQC/l0qfzXm1IK8UfCrHgjox2/7zRn""ZwrSSdYJ7iYDAvPMzeqK1TGoLY8D/V785DrGiWeZTM6YbfqEDQ5Ti+ZjUsWbSqmrn""oyI1mQ3uGf+bLfWkd/LsEID0q4K50X42Hw6fmxmg9cNX3Yi7zuGQnD9Lut06qUGzn""3YZNwsK36P83E8AEiUNEOBHmo5b3CSIhLyxODn7l2Fy7AERbr97ks7DwPLY4RUldn""AgMBAAGjggaPMIIGizAOBgNVHQ8BAf8EBAMCBaAwgY4GCCsGAQUFBwEBBIGBMH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Wpp6uCjWPkXn""1a3kdzajezONw5Uwdn7l+xypjE6bdwIgG2GK8pH+5UqZTTKxNyqCRoiJDX7rAXzxn""O22aIRkkBcAwDQYJKoZIhvcNAQELBQADggEBABlaZ1BDsax6k6hoGHKLQH6mdd6sn""IfzJQRYgS/OMC7lHRa74XXn2QzUmAZjwuYY+KQHx37Byta540t9htnhnisl3mt7gn""5EEvnB7lO3yXP0IvreNJf50rAoiQaSUDARS5tcsPWT0tlz0C1VGQaQyBECLaxlHvn""SAzST95h8mqHFaVtcY43AqKFDx4ZdaOALmoaogKML+y9PYEDP4rAoOa0DghXywAcn""ircbjzhxmo3AcQw/vNS+Vp33GMGqvuTfGobiYm8jhjBUeC1HH7StBSlzJJgUoBnAn""Av2QkE5iXOhNMYnD6Iuec1k7mJHKR6UFW8Uej4U5Ds61JgqATp8IShFJE2M=n""-----END CERTIFICATE-----n";esp_err_t _http_event_handler(esp_http_client_event_t* evt) { if (evt->event_id == HTTP_EVENT_ON_DATA) { httpResponseString.concat((char*)evt->data); } return ESP_OK;}String recognizeImage(String image) { httpResponseString = ""; esp_http_client_handle_t http_client; esp_http_client_config_t config_client = { 0 }; config_client.url = post_url; config_client.event_handler = _http_event_handler; config_client.auth_type = HTTP_AUTH_TYPE_NONE; config_client.cert_pem =root_ca; config_client.client_cert_len= strlen(root_ca)+1; config_client.skip_cert_common_name_check = true; config_client.buffer_size_tx =313000; config_client.transport_type = HTTP_TRANSPORT_OVER_TCP; config_client.method = HTTP_METHOD_POST; |
|
相关推荐
1个回答
|
|
要解决Arduino IDE开发ESP32 CAM模块HTTPS无法正确读取证书的问题,请按照以下步骤操作:
1. 确认证书格式:确保您使用的是正确的证书格式。通常,HTTPS证书是PEM格式(以"-----BEGIN CERTIFICATE-----"开头,以"-----END CERTIFICATE-----"结尾)。如果证书格式不正确,请使用在线工具或软件将其转换为PEM格式。 2. 将证书转换为C语言字符串:在Arduino IDE中,您需要将证书转换为C语言字符串。这可以通过手动将证书文本复制到代码中或使用在线工具自动生成C语言字符串来完成。 3. 包含所需的库:确保您的Arduino代码中包含了所需的库,例如`WiFi.h`、`HTTPClient.h`等。 4. 配置ESP32 CAM模块:在代码中配置ESP32 CAM模块的WiFi连接参数,包括SSID和密码。 5. 设置HTTPS客户端:创建一个`HTTPClient`对象,并使用`begin()`方法设置目标URL。 6. 设置证书:使用`setCACert()`方法为`HTTPClient`对象设置证书。将证书作为参数传递给此方法。 7. 发送HTTPS请求:使用`GET`、`POST`等方法发送HTTPS请求。 8. 检查响应:检查返回的响应状态码和内容,以确保请求成功。 9. 调试:如果仍然无法正确读取证书,请检查以下几点: - 确保证书是有效的,并且与目标服务器匹配。 - 检查网络连接是否稳定。 - 查看ESP32 CAM模块的日志,以获取有关错误的详细信息。 以下是一个简单的示例代码,展示了如何使用ESP32 CAM模块发送HTTPS请求: ```cpp #include #include const char* ssid = "your_SSID"; const char* password = "your_PASSWORD"; const char* serverName = "your_server_name"; const char* fingerprint = "your_fingerprint"; const char* caCert = "-----BEGIN CERTIFICATE-----n" "your_certificate_content" "-----END CERTIFICATE-----n"; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial.println("Connecting to WiFi..."); } Serial.println("Connected to WiFi"); Serial.println("IP address: " + WiFi.localIP().toString()); HTTPClient https; https.begin(serverName, fingerprint, 443, "/your_path", caCert); int httpCode = https.GET(); if (httpCode > 0) { Serial.println(httpCode); Serial.println(https.getString()); } else { Serial.println("Error on HTTP request"); } https.end(); } void loop() { // Nothing to do here } ``` 请根据您的实际情况替换示例代码中的占位符(如`your_SSID`、`your_PASSWORD`等)。希望这能帮助您解决问题。 |
|
|
|
只有小组成员才能发言,加入小组>>
1108 浏览 1 评论
574浏览 6评论
477浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
460浏览 5评论
461浏览 4评论
435浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 23:53 , Processed in 0.886050 second(s), Total 77, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号