error: too few arguments to function ‘ngx_ssl_session_cache’

error: too few arguments to function ‘ngx_ssl_session_cache’

环境

Nginx version 1.18.0
CentOS 7

添加ngx_tcp_ssl_moduleMake 时报错
                               ~~~~^~~~~~~~~~
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值