error: too few arguments to function ‘ngx_ssl_session_cache’
环境
Nginx version 1.18.0
CentOS 7
添加ngx_tcp_ssl_module
Make 时报错
~~~~^~~~~~~~~~
In file included from src/core/ngx_core.h:84,
from /usr/local/src/nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.c:3:
src/event/ngx_event_openssl.h:195:40: note: expected ‘ssize_t’ {aka ‘long int’} but argument is of type ‘ngx_shm_zone_t *’ {aka ‘struct ngx_shm_zone_s *’}
ngx_array_t *certificates, ssize_t builtin_session_cache,
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/local/src/nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.c:409:51: warning: passing argument 5 of ‘ngx_ssl_session_cache’ makes pointer from integer without a cast [-Wint-conversion]
conf->shm_zone, conf->session_timeout)
~~~~^~~~~~~~~~~~~~~~~
In file included from src/core/ngx_core.h:84,
from /usr/local/src/nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.c:3:
src/event/ngx_event_openssl.h:196:21: note: expected ‘ngx_shm_zone_t *’ {aka ‘struct ngx_shm_zone_s *’} but argument is of type ‘time_t’ {aka ‘long int’}
ngx_shm_zone_t *shm_zone, time_t timeout);
~~~~~~~~~~~~~~~~^~~~~~~~
/usr/local/src/nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.c:407:9: error: too few arguments to function ‘ngx_ssl_session_cache’
if (ngx_ssl_session_cache(&conf->ssl, &ngx_tcp_ssl_sess_id_ctx,
^~~~~~~~~~~~~~~~~~~~~
In file included from src/core/ngx_core.h:84,
from /usr/local/src/nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.c:3:
src/event/ngx_event_openssl.h:194:11: note: declared here
ngx_int_t ngx_ssl_session_cache(ngx_ssl_t *ssl, ngx_str_t *sess_ctx,
^~~~~~~~~~~~~~~~~~~~~
问题原因
nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.c
文件中调用ngx_ssl_session_cache
方法传入的参数与./nginx-1.18.0/src/event/ngx_event.h
文件中声明的参数个数不同。调用时缺少一个ngx_array_t *certificates
类型的参数.
// ./nginx-1.18.0/src/event/ngx_event.h文件 方法声明
ngx_int_t ngx_ssl_session_cache(ngx_ssl_t *ssl, ngx_str_t *sess_ctx,
ngx_array_t *certificates, ssize_t builtin_session_cache,
ngx_shm_zone_t *shm_zone, time_t timeout);
// /nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.c文件 方法调用
if (ngx_ssl_session_cache(&conf->ssl, &ngx_tcp_ssl_sess_id_ctx,
// 报错原因:此处缺少一个 ngx_array_t *certificates 类型的参数
conf->builtin_session_cache,
conf->shm_zone, conf->session_timeout)
!= NGX_OK)
{
return NGX_CONF_ERROR;
}
问题解决
nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.h
文件中可查看到ngx_tcp_ssl_srv_conf_t
结构体中所定义的ngx_array_t *certificates
类型属性*passwords
。通过位置比对,将conf->passwords
作为ngx_ssl_session_cache
调用时ngx_array_t *certificates
参数类型的实参。
// nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.h文件 查找定义
typedef struct {
ngx_flag_t enable;
ngx_ssl_t ssl;
ngx_flag_t prefer_server_ciphers;
ngx_uint_t protocols;
ngx_uint_t verify;
ngx_uint_t verify_depth;
ssize_t builtin_session_cache;
time_t session_timeout;
ngx_str_t certificate;
ngx_str_t certificate_key;
ngx_str_t dhparam;
#if defined(nginx_version) && nginx_version >= 1000006
ngx_str_t ecdh_curve;
#endif
ngx_str_t client_certificate;
ngx_str_t crl;
ngx_str_t ciphers;
#if defined(nginx_version) && nginx_version >= 1007003
// 找到 ngx_array_t 类型的属性定义
ngx_array_t *passwords;
#endif
ngx_shm_zone_t *shm_zone;
u_char *file;
ngx_uint_t line;
} ngx_tcp_ssl_srv_conf_t;
// /nginx_tcp_proxy_module-master/modules/ngx_tcp_ssl_module.c文件 添加参数
if (ngx_ssl_session_cache(&conf->ssl, &ngx_tcp_ssl_sess_id_ctx,
// 此处添加 ngx_array_t *certificates 类型的参数 conf->passwords
conf->passwords,
conf->builtin_session_cache,
conf->shm_zone, conf->session_timeout)
!= NGX_OK)
{
return NGX_CONF_ERROR;
}
重新
make & make install