mirror of
https://github.com/nginx/nginx.git
synced 2026-06-26 11:52:00 +00:00
$ssl_session_id
This commit is contained in:
parent
f63a48ce7e
commit
cdaf442a2f
3 changed files with 39 additions and 0 deletions
|
|
@ -1928,6 +1928,40 @@ ngx_ssl_get_cipher_name(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
|
|||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
|
||||
{
|
||||
int len;
|
||||
u_char *p, *buf;
|
||||
SSL_SESSION *sess;
|
||||
|
||||
sess = SSL_get0_session(c->ssl->connection);
|
||||
|
||||
len = i2d_SSL_SESSION(sess, NULL);
|
||||
|
||||
buf = ngx_alloc(len, c->log);
|
||||
if (buf == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
s->len = 2 * len;
|
||||
s->data = ngx_pnalloc(pool, 2 * len);
|
||||
if (s->data == NULL) {
|
||||
ngx_free(p);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
p = buf;
|
||||
i2d_SSL_SESSION(sess, &p);
|
||||
|
||||
ngx_hex_dump(s->data, buf, len);
|
||||
|
||||
ngx_free(buf);
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_ssl_get_raw_certificate(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -118,6 +118,8 @@ ngx_int_t ngx_ssl_get_protocol(ngx_connection_t *c, ngx_pool_t *pool,
|
|||
ngx_str_t *s);
|
||||
ngx_int_t ngx_ssl_get_cipher_name(ngx_connection_t *c, ngx_pool_t *pool,
|
||||
ngx_str_t *s);
|
||||
ngx_int_t ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool,
|
||||
ngx_str_t *s);
|
||||
ngx_int_t ngx_ssl_get_raw_certificate(ngx_connection_t *c, ngx_pool_t *pool,
|
||||
ngx_str_t *s);
|
||||
ngx_int_t ngx_ssl_get_certificate(ngx_connection_t *c, ngx_pool_t *pool,
|
||||
|
|
|
|||
|
|
@ -184,6 +184,9 @@ static ngx_http_variable_t ngx_http_ssl_vars[] = {
|
|||
{ ngx_string("ssl_cipher"), NULL, ngx_http_ssl_static_variable,
|
||||
(uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGEABLE, 0 },
|
||||
|
||||
{ ngx_string("ssl_session_id"), NULL, ngx_http_ssl_variable,
|
||||
(uintptr_t) ngx_ssl_get_session_id, NGX_HTTP_VAR_CHANGEABLE, 0 },
|
||||
|
||||
{ ngx_string("ssl_client_cert"), NULL, ngx_http_ssl_variable,
|
||||
(uintptr_t) ngx_ssl_get_certificate, NGX_HTTP_VAR_CHANGEABLE, 0 },
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue