|
31 | 31 | #include "ngx_stream_lua_ssl_client_helloby.h" |
32 | 32 | #include "ngx_stream_lua_ssl_certby.h" |
33 | 33 |
|
| 34 | +#ifdef HAVE_PROXY_SSL_PATCH |
| 35 | +#include "ngx_stream_lua_proxy_ssl_verifyby.h" |
| 36 | +#endif |
| 37 | + |
34 | 38 |
|
35 | 39 | #include "ngx_stream_lua_prereadby.h" |
36 | 40 |
|
@@ -422,6 +426,30 @@ static ngx_command_t ngx_stream_lua_cmds[] = { |
422 | 426 | 0, |
423 | 427 | (void *) ngx_stream_lua_ssl_cert_handler_file }, |
424 | 428 |
|
| 429 | +#ifdef HAVE_PROXY_SSL_PATCH |
| 430 | + /* same context as proxy_pass directive */ |
| 431 | + { ngx_string("proxy_ssl_verify_by_lua_block"), |
| 432 | + NGX_STREAM_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, |
| 433 | + ngx_stream_lua_proxy_ssl_verify_by_lua_block, |
| 434 | + NGX_STREAM_SRV_CONF_OFFSET, |
| 435 | + 0, |
| 436 | + (void *) ngx_stream_lua_proxy_ssl_verify_handler_inline }, |
| 437 | + |
| 438 | + { ngx_string("proxy_ssl_verify_by_lua_file"), |
| 439 | + NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, |
| 440 | + ngx_stream_lua_proxy_ssl_verify_by_lua, |
| 441 | + NGX_STREAM_SRV_CONF_OFFSET, |
| 442 | + 0, |
| 443 | + (void *) ngx_stream_lua_proxy_ssl_verify_handler_file }, |
| 444 | + |
| 445 | + { ngx_string("lua_upstream_skip_openssl_default_verify"), |
| 446 | + NGX_STREAM_SRV_CONF|NGX_CONF_FLAG, |
| 447 | + ngx_conf_set_flag_slot, |
| 448 | + NGX_STREAM_SRV_CONF_OFFSET, |
| 449 | + offsetof(ngx_stream_lua_srv_conf_t, |
| 450 | + ups.upstream_skip_openssl_default_verify), |
| 451 | + NULL }, |
| 452 | +#endif |
425 | 453 |
|
426 | 454 | { ngx_string("lua_ssl_verify_depth"), |
427 | 455 | NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, |
@@ -827,6 +855,10 @@ ngx_stream_lua_create_srv_conf(ngx_conf_t *cf) |
827 | 855 | * lscf->srv.ssl_client_hello_src = { 0, NULL }; |
828 | 856 | * lscf->srv.ssl_client_hello_src_key = NULL; |
829 | 857 | * |
| 858 | + * lscf->ups.proxy_ssl_verify_handler = NULL; |
| 859 | + * lscf->ups.proxy_ssl_verify_src = { 0, NULL }; |
| 860 | + * lscf->ups.proxy_ssl_verify_src_key = NULL; |
| 861 | + * |
830 | 862 | * lscf->srv.ssl_cert_handler = NULL; |
831 | 863 | * lscf->srv.ssl_cert_src = { 0, NULL }; |
832 | 864 | * lscf->srv.ssl_cert_src_key = NULL; |
@@ -868,6 +900,9 @@ ngx_stream_lua_create_srv_conf(ngx_conf_t *cf) |
868 | 900 | conf->ssl_verify_depth = NGX_CONF_UNSET_UINT; |
869 | 901 | conf->ssl_certificates = NGX_CONF_UNSET_PTR; |
870 | 902 | conf->ssl_certificate_keys = NGX_CONF_UNSET_PTR; |
| 903 | +#ifdef HAVE_PROXY_SSL_PATCH |
| 904 | + conf->ups.upstream_skip_openssl_default_verify = NGX_CONF_UNSET; |
| 905 | +#endif |
871 | 906 | #endif |
872 | 907 |
|
873 | 908 | return conf; |
@@ -1002,6 +1037,23 @@ ngx_stream_lua_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
1002 | 1037 | NULL); |
1003 | 1038 | #endif |
1004 | 1039 |
|
| 1040 | +#ifdef HAVE_PROXY_SSL_PATCH |
| 1041 | + if (conf->ups.proxy_ssl_verify_src.len == 0) { |
| 1042 | + conf->ups.proxy_ssl_verify_src = prev->ups.proxy_ssl_verify_src; |
| 1043 | + conf->ups.proxy_ssl_verify_handler = prev->ups.proxy_ssl_verify_handler; |
| 1044 | + conf->ups.proxy_ssl_verify_src_key = prev->ups.proxy_ssl_verify_src_key; |
| 1045 | + } |
| 1046 | + |
| 1047 | + if (conf->ups.proxy_ssl_verify_src.len) { |
| 1048 | + if (ngx_stream_lua_proxy_ssl_verify_set_callback(cf) != NGX_OK) { |
| 1049 | + return NGX_CONF_ERROR; |
| 1050 | + } |
| 1051 | + } |
| 1052 | + |
| 1053 | + ngx_conf_merge_value(conf->ups.upstream_skip_openssl_default_verify, |
| 1054 | + prev->ups.upstream_skip_openssl_default_verify, 0); |
| 1055 | +#endif |
| 1056 | + |
1005 | 1057 | if (ngx_stream_lua_set_ssl(cf, conf) != NGX_OK) { |
1006 | 1058 | return NGX_CONF_ERROR; |
1007 | 1059 | } |
|
0 commit comments