Rework mbedtls CRL handling
A message that is not in the archive (sent off-list or not yet received): [email protected]...
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Hi Max,
Quoted 10 lines · Max Fillinger
This commit fixes the following two issues:
The config belonging to a
mbedtls_ssl_ctxstruct is not supposed to be changed aftermbedtls_ssl_setup()has been called. Previously, we modified the CRL structure in place when a new CRL was loaded, but a pointer to this struct appears in configs that are currently in use.This commit uses reference counting to ensure that CRLs remain in memory while the
mbedtls_ssl_ctxstruct and config remain.
To fix this issue, wouldn't be enough to reload the CRL *before* calling mbedtls_ssl_setup()?
This way we know that a new ssl_ctx is always initialized with the latest CRL, rather than having the old one still around?
I have attached a proposal for your review. Please let me know what you think about it.
As a side note: how did you notice this issue?
Quoted 3 lines
The other issue fixed by this commit is that, if OpenVPN failed to read the CRL in
init_ssl(), but succeeded in reading it later, it would not actually use that CRL.
Mh... I have tried to reproduce this issue, but I was not able to. Would you be able to provide me with the exact steps to hit this situation?
What I tried was:
1) create empty file crl.pem;
2) start server with --crl-verify crl.pem;
3) connect with client -> connection denied due to verification issue (VERIFY ERROR: CRL not loaded);
4) I overwrote crl.pem with a real CRL (without restarting the server);
5) I connected with my client and it worked;
6) I connected with a certificate in the CRL -> connection denied.
Btw, Signed-off-by line is missing - a patch submitted for inclusion should always have one.
Regards,
Signature · 1 line
Antonio Quartulli
src/openvpn/ssl.c +11 -11
@@ -899,6 +899,17 @@ key_state_init(struct tls_session *session, struct key_state *ks)CLEAR (*ks); +/* +* Attempt CRL reload before any TLS operation. Won't be performed if +* the file was not modified since the last reload +*/ +if (session->opt->crl_file + && !(session->opt->ssl_flags &SSLF_CRL_VERIFY_DIR )) + { +tls_ctx_reload_crl (&session->opt->ssl_ctx, session->opt->crl_file, + session->opt->crl_file_inline); + } +/* * Build TLS object that reads/writes ciphertext * to/from memory BIOs.
@@ -2728,17 +2739,6 @@ tls_process(struct tls_multi *multi, ks->state =S_START ; state_change = true; -/* -* Attempt CRL reload before TLS negotiation. Won't be performed if -* the file was not modified since the last reload -*/ -if (session->opt->crl_file - && !(session->opt->ssl_flags &SSLF_CRL_VERIFY_DIR )) - { -tls_ctx_reload_crl (&session->opt->ssl_ctx, - session->opt->crl_file, session->opt->crl_file_inline); - } -/* New connection, remove any old X509 env variables */ tls_x509_clear_env (session->opt->es);
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Hi Max,
I was starting to comment to the various points in this email, but I believe it was getting confusing.
Now that I have a better overview (thanks to your explanations!) I would suggest splitting the problem in smaller sub-problems to help our discussion.
[Later it'd be very nice to have one patch per problem being fixed too]
To the best of my understand we have the following problems that needs fixing:
1) CRL being changed in-place, even though we may prefer not doing that;
2) --chroot messing up paths in pre- and post-chroot operations;
3) CRL not being used at all if OpenVPN failed to parse it during initialization;
4) different CRL access/parsing errors handled differently.
Is the summary above correct? or is any of my points wrong/lacking details?
[If you prefer discussing on IRC, feel free to join #openvpn-devel on freenode]
Regards,
Signature · 1 line
Antonio Quartulli