When we re-use previously saved SSL_SESSION
,
does the reused SSL session have orignal X.509 peer certificate?
My code crashes very infrequently and investigation showed that
the SSL session is reused and the some fields of peer cert(certinfo->key->pkey
) are messed up.
1st Handshake from CLT to SVR.
SVR sends X.509 certificate to CLT and CLT stores the cert. We can get the cert using
SSL_get_peer_certificate()
. CLT saves theSSL_SESSION
withSSL_get1_session()
.2nd Handshake from CLT to SVR.
This time CLT offers saved
SSL_SESSION
withSSL_set_session()
and abbreviated handshake occured. When CLT callsSSL_get_peer_certificate()
, can CLT get the original X.509 cert?
It seems that coupling with SSL_SESSION
and included peer X.509 cert is loose. Should we save X.509 peer cert with upping refcnt explicitly, in addition to calling SSL_get1_session
just, to properly use SSL_get_peer_certificate()
on reused SSL_SESSION
?
I use LibreSSL and OpenSSL on Linux.
Any comments would be appreciated deeply.
If you see openssl code you will find this comment, in declaration of
SSL_SESSION
, it says:I would assume it indicates for clients, peer certificate is not retained when converted to external representation ie when SSL_SESSION is serialised peer certificated will be lost