mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(esp_http_server): Allow the https server to request client certs optionally
Closes https://github.com/espressif/esp-idf/pull/17641
This commit is contained in:
committed by
Ashish Sharma
parent
82e525ef3e
commit
2ed84eb04b
@@ -62,13 +62,14 @@ menu "ESP-TLS"
|
||||
config ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL
|
||||
bool "ESP-TLS Server: Set minimum Certificate Verification mode to Optional"
|
||||
depends on ESP_TLS_USING_MBEDTLS
|
||||
default n
|
||||
help
|
||||
When this option is enabled, the peer (here, the client) certificate is checked by the server,
|
||||
however the handshake continues even if verification failed. By default, the
|
||||
peer certificate is not checked and ignored by the server.
|
||||
When this option is enabled, the ESP-TLS server can be configured to
|
||||
request client certificates optionally. This is done by setting the
|
||||
client_cert_authmode_optional field in the esp_https_server_config_t structure.
|
||||
|
||||
mbedtls_ssl_get_verify_result() can be called after the handshake is complete to
|
||||
retrieve status of verification.
|
||||
retrieve status of verification of the client certificate, if presented.
|
||||
|
||||
config ESP_TLS_PSK_VERIFICATION
|
||||
bool "Enable PSK verification"
|
||||
|
||||
@@ -296,6 +296,10 @@ typedef struct esp_tls_cfg_server {
|
||||
unsigned int cacert_pem_bytes; /*!< Size of client CA certificate legacy name */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL
|
||||
bool client_cert_authmode_optional; /*!< Set client certificate authentication mode to optional.
|
||||
By default, client certificate authentication mode is set to required */
|
||||
#endif // CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL
|
||||
union {
|
||||
const unsigned char *servercert_buf; /*!< Server certificate in a buffer
|
||||
This buffer should be NULL terminated */
|
||||
|
||||
@@ -757,12 +757,11 @@ static esp_err_t set_server_config(esp_tls_cfg_server_t *cfg, esp_tls_t *tls)
|
||||
if (esp_ret != ESP_OK) {
|
||||
return esp_ret;
|
||||
}
|
||||
} else {
|
||||
#ifdef CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL
|
||||
mbedtls_ssl_conf_authmode(&tls->conf, MBEDTLS_SSL_VERIFY_OPTIONAL);
|
||||
#else
|
||||
mbedtls_ssl_conf_authmode(&tls->conf, MBEDTLS_SSL_VERIFY_NONE);
|
||||
#endif
|
||||
if (cfg->client_cert_authmode_optional) {
|
||||
mbedtls_ssl_conf_authmode(&tls->conf, MBEDTLS_SSL_VERIFY_OPTIONAL);
|
||||
}
|
||||
#endif // CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL
|
||||
}
|
||||
|
||||
if (cfg->use_secure_element) {
|
||||
|
||||
Reference in New Issue
Block a user