Skip to content

Commit

Permalink
Move peer chain to SSL_SESSION structure.
Browse files Browse the repository at this point in the history
Reviewed-by: Richard Levitte <[email protected]>
  • Loading branch information
snhenson committed Jun 22, 2015
1 parent 8df53b7 commit c34b0f9
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ssl/s3_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ int ssl3_get_server_certificate(SSL *s)
ssl_sess_cert_free(s->session->sess_cert);
s->session->sess_cert = sc;

sc->cert_chain = sk;
s->session->peer_chain = sk;
/*
* Inconsistency alert: cert_chain does include the peer's certificate,
* which we don't include in s3_srvr.c
Expand Down
4 changes: 2 additions & 2 deletions ssl/s3_srvr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3206,8 +3206,8 @@ int ssl3_get_client_certificate(SSL *s)
goto done;
}
}
sk_X509_pop_free(s->session->sess_cert->cert_chain, X509_free);
s->session->sess_cert->cert_chain = sk;
sk_X509_pop_free(s->session->peer_chain, X509_free);
s->session->peer_chain = sk;
/*
* Inconsistency alert: cert_chain does *not* include the peer's own
* certificate, while we do include it in s3_clnt.c
Expand Down
1 change: 0 additions & 1 deletion ssl/ssl_cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ void ssl_sess_cert_free(SESS_CERT *sc)
#endif

/* i == 0 */
sk_X509_pop_free(sc->cert_chain, X509_free);
OPENSSL_free(sc);
}

Expand Down
5 changes: 2 additions & 3 deletions ssl/ssl_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,11 +834,10 @@ STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s)
{
STACK_OF(X509) *r;

if ((s == NULL) || (s->session == NULL)
|| (s->session->sess_cert == NULL))
if ((s == NULL) || (s->session == NULL))
r = NULL;
else
r = s->session->sess_cert->cert_chain;
r = s->session->peer_chain;

/*
* If we are a client, cert_chain includes the peer's own certificate; if
Expand Down
3 changes: 2 additions & 1 deletion ssl/ssl_locl.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ struct ssl_session_st {
/* This is the cert and type for the other end. */
X509 *peer;
int peer_type;
/* Certificate chain of peer */
STACK_OF(X509) *peer_chain;
/*
* when app_verify_callback accepts a session where the peer's
* certificate is not ok, we must remember the error for session reuse:
Expand Down Expand Up @@ -1587,7 +1589,6 @@ typedef struct cert_st {
} CERT;

typedef struct sess_cert_st {
STACK_OF(X509) *cert_chain; /* as received from peer */
int references; /* actually always 1 at the moment */
} SESS_CERT;
/* Structure containing decoded values of signature algorithms extension */
Expand Down
1 change: 1 addition & 0 deletions ssl/ssl_sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ void SSL_SESSION_free(SSL_SESSION *ss)
OPENSSL_cleanse(ss->session_id, sizeof ss->session_id);
ssl_sess_cert_free(ss->sess_cert);
X509_free(ss->peer);
sk_X509_pop_free(ss->peer_chain, X509_free);
sk_SSL_CIPHER_free(ss->ciphers);
OPENSSL_free(ss->tlsext_hostname);
OPENSSL_free(ss->tlsext_tick);
Expand Down

0 comments on commit c34b0f9

Please sign in to comment.