Skip to content

vtls/openssl: Support async certificate verification by user callback - #11499

Closed
pabusse wants to merge 6 commits into
curl:masterfrom
pabusse:openssl_async_tls_verify
Closed

vtls/openssl: Support async certificate verification by user callback#11499
pabusse wants to merge 6 commits into
curl:masterfrom
pabusse:openssl_async_tls_verify

Conversation

@pabusse

@pabusse pabusse commented Jul 21, 2023

Copy link
Copy Markdown
Contributor

Overview

Update the OpenSSL connect state machine to handle SSL_ERROR_WANT_RETRY_VERIFY. This allows libcurl users to suspend processing while waiting for external I/O during certificate validation.

Intended usage

Clients perform asynchronous certificate verification by installing a X.509 certificate verification function with SSL_CTX_set_cert_verify_callback from the SSL context callback (see CURLOPT_SSL_CTX_FUNCTION).

The verification function calls SSL_set_retry_verify before returning 0 to indicate that the outcome is still pending. Once verification completes, the client calls curl_multi_wakeup to re-enter the SSL_connect state machine and return the final verification outcome from the next call to the verification function.

This mechanism is useful for applications that use OpenSSL for TLS protocol handling and crypto while delegating certificate verification to the platform's native trust store.

@github-actions github-actions Bot added the TLS label Jul 21, 2023
@bagder

bagder commented Jul 22, 2023

Copy link
Copy Markdown
Member

This allows libcurl users to suspend processing while waiting for external I/O during certificate validation

Shouldn't this then also be documented somewhere?

@pabusse

pabusse commented Jul 24, 2023

Copy link
Copy Markdown
Contributor Author

Shouldn't this then also be documented somewhere?

Added a section on custom certificate verification with OpenSSL. Please take a look.

@jay

jay commented Jul 29, 2023

Copy link
Copy Markdown
Member

This is highly advanced and too niche to document in SSLCERTS. Instead, I suggest add a concise paragraph above the WARNING paragraphs in CURLOPT_SSL_CTX_FUNCTION: "For OpenSSL, error code SSL_ERROR_WANT_RETRY_VERIFY is supported for custom certificate verification. (Added in 8.3.0)". Anyone who is using a custom CTX function it's up to them to investigate all of the details. There's such a thing as too much documentation.

Comment thread docs/libcurl/opts/CURLOPT_SSL_CTX_FUNCTION.3 Outdated
@jay jay closed this in 11d46bc Aug 1, 2023
@jay

jay commented Aug 1, 2023

Copy link
Copy Markdown
Member

Thanks

ptitSeb pushed a commit to wasix-org/curl that referenced this pull request Sep 25, 2023
- Update the OpenSSL connect state machine to handle
  SSL_ERROR_WANT_RETRY_VERIFY.

This allows libcurl users that are using custom certificate validation
to suspend processing while waiting for external I/O during certificate
validation.

Closes curl#11499
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants