feat(esp_http_client): Allow the DER certificates in esp_http_client

- esp_http_client support just PEM ca_cert and client_cert.
- Although esp_tls supports both PEM and DER certificate. We have logic
based on cert_len and client_cert_len which decides whether given cert or client_cert
is in PEM or DER format.
- If length is 0 then it is PEM certificate and if length is passed then DER is
considered. This is true for both ca_cert and client_cert

This commits allow to pass the DER certificate in esp_http_client
This commit is contained in:
hrushikesh.bhosale
2025-04-15 10:07:05 +05:30
committed by Aditya Patwardhan
parent 33cab69f30
commit 846a5c42ae

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -150,10 +150,20 @@ typedef struct {
esp_http_client_auth_type_t auth_type; /*!< Http authentication type, see `esp_http_client_auth_type_t` */
const char *path; /*!< HTTP Path, if not set, default is `/` */
const char *query; /*!< HTTP query */
const char *cert_pem; /*!< SSL server certification, PEM format as string, if the client requires to verify server */
size_t cert_len; /*!< Length of the buffer pointed to by cert_pem. May be 0 for null-terminated pem */
const char *client_cert_pem; /*!< SSL client certification, PEM format as string, if the server requires to verify client */
size_t client_cert_len; /*!< Length of the buffer pointed to by client_cert_pem. May be 0 for null-terminated pem */
union {
const char *cert_pem; /*!< SSL server certification, PEM format as string, if the client requires to verify server */
const char *cert_der; /*!< SSL server certification, DER format as binary, if the client requires to verify server */
};
size_t cert_len; /*!< Length of the buffer pointed to by cert_pem or cert_der.
PEM Certificate - Length of the buffer pointed to by cert_pem. Length should be the length of the certificate including NULL terminator or 0.
DER Certificate - Length of the buffer pointed to by cert_der. Should be the length of the certificate. */
union {
const char *client_cert_pem; /*!< SSL client certification, PEM format as string, if the server requires to verify client */
const char *client_cert_der; /*!< SSL client certification, DER format as binary, if the server requires to verify client */
};
size_t client_cert_len; /*!< Length of the buffer pointed to by client_cert_pem or client_cert_der.
PEM Certificate - Length of the buffer pointed to by client_cert_pem. Length should be the length of the certificate including NULL terminator or 0.
DER Certificate - Length of the buffer pointed to by client_cert_der. Should be the length of the certificate. */
const char *client_key_pem; /*!< SSL client key, PEM format as string, if the server requires to verify client */
size_t client_key_len; /*!< Length of the buffer pointed to by client_key_pem. May be 0 for null-terminated pem */
const char *client_key_password; /*!< Client key decryption password string */