Klaus Demo nginx / cdaf442
$ssl_session_id Igor Sysoev 12 years ago
3 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
19281928
19291929
19301930 ngx_int_t
1931 ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
1932 {
1933 int len;
1934 u_char *p, *buf;
1935 SSL_SESSION *sess;
1936
1937 sess = SSL_get0_session(c->ssl->connection);
1938
1939 len = i2d_SSL_SESSION(sess, NULL);
1940
1941 buf = ngx_alloc(len, c->log);
1942 if (buf == NULL) {
1943 return NGX_ERROR;
1944 }
1945
1946 s->len = 2 * len;
1947 s->data = ngx_pnalloc(pool, 2 * len);
1948 if (s->data == NULL) {
1949 ngx_free(p);
1950 return NGX_ERROR;
1951 }
1952
1953 p = buf;
1954 i2d_SSL_SESSION(sess, &p);
1955
1956 ngx_hex_dump(s->data, buf, len);
1957
1958 ngx_free(buf);
1959
1960 return NGX_OK;
1961 }
1962
1963
1964 ngx_int_t
19311965 ngx_ssl_get_raw_certificate(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
19321966 {
19331967 size_t len;
117117 ngx_str_t *s);
118118 ngx_int_t ngx_ssl_get_cipher_name(ngx_connection_t *c, ngx_pool_t *pool,
119119 ngx_str_t *s);
120 ngx_int_t ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool,
121 ngx_str_t *s);
120122 ngx_int_t ngx_ssl_get_raw_certificate(ngx_connection_t *c, ngx_pool_t *pool,
121123 ngx_str_t *s);
122124 ngx_int_t ngx_ssl_get_certificate(ngx_connection_t *c, ngx_pool_t *pool,
183183 { ngx_string("ssl_cipher"), NULL, ngx_http_ssl_static_variable,
184184 (uintptr_t) ngx_ssl_get_cipher_name, NGX_HTTP_VAR_CHANGEABLE, 0 },
185185
186 { ngx_string("ssl_session_id"), NULL, ngx_http_ssl_variable,
187 (uintptr_t) ngx_ssl_get_session_id, NGX_HTTP_VAR_CHANGEABLE, 0 },
188
186189 { ngx_string("ssl_client_cert"), NULL, ngx_http_ssl_variable,
187190 (uintptr_t) ngx_ssl_get_certificate, NGX_HTTP_VAR_CHANGEABLE, 0 },
188191