Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for mutual authentication in esp_http_client #2688

Closed

Conversation

AndersKaloer
Copy link
Contributor

Add support for TLS mutual authentication (implemented recently in #2490) in esp_http_client.

This is very convenient for OTA updates, and has been tested with esp_https_ota and nginx.

@CLAassistant
Copy link

CLAassistant commented Nov 10, 2018

CLA assistant check
All committers have signed the CLA.

@igrr igrr requested review from tuanpmt and mahavirj January 18, 2019 09:15
@kifantidis
Copy link

I hope this goes on and get implemented in the esp-idf :/ I've tried the code changes today as AndersKaloer sugest but my code seems not to be using mutual auth.
After inserting the 2 crt pem files + the priv key +url (the link of the bin file), I've got in return this message:

I (4688) event: sta ip: 10.0.0.174, mask: 255.255.255.0, gw: 10.0.0.2
I (4688) simple_ota_example: Connect to Wifi ! Start to Connect to Server....
E (5838) esp-tls: read error :-30592:
E (5838) TRANS_SSL: esp_tls_conn_read error, errno=Success errno=0
I (5838) esp_https_ota: Starting OTA...
I (5838) esp_https_ota: Writing to partition subtype 16 at offset 0x110000
I (5858) esp_https_ota: esp_ota_begin succeeded
I (5858) esp_https_ota: Please Wait. This may take time
I (5858) esp_https_ota: Connection closed,all data received
E (5868) esp_https_ota: Error: esp_ota_end failed! err=0x258. Image is invalid
E (5878) simple_ota_example: Firmware Upgrades Failed

I contacted with my colleague that handles the server in order to get my hands on the server's log files.
What i found there was this message: "Re-negotiation handshake failed: Client certificate missing"
Does this mean that Client certificate is wrong or something else ? :-/

Any help would be greatly appreciated.
Best regards, Kostas

@AndersKaloer
Copy link
Contributor Author

Kostas,
It is difficult to help you based on the limited information that you provide.
It seems like you are using an Apache web server. I have been able to verify the implementation with Apache2 using the SSLVerifyClient require directive. You also need to provide the SSLCACertificateFile directive in order to enable client authentication.
In addition to the directives mentioned above, SSLCertificateFile and SSLCertificateKeyFile are needed for server authentication.

There are several guides available on the Internet on how to configure mutual authentication in Apache2. I suggest you to follow one of these and verify your setup using e.g. wget before you try to implement it on the ESP32.

The same thing can be achieved with nginx using the ssl_verify_client and ssl_client_certificate directives (in addition to ssl_certificate and ssl_certificate_key used for server authentication).

Copy link
Contributor

@tuanpmt tuanpmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this feature to esp_http_client

@igrr igrr closed this in 8b72dc9 Jan 24, 2019
@AndersKaloer AndersKaloer deleted the https-mutual-auth branch January 26, 2019 14:13
igrr pushed a commit that referenced this pull request May 27, 2019
0xFEEDC0DE64 pushed a commit to 0xFEEDC0DE64/esp-idf that referenced this pull request May 5, 2021
* add support for CORS headers

* remove accidental function impl

* rename setCORS to enableCORS, and add aliased function enableCrossOrigin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants