-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathngx_gridproxy_module.c
74 lines (63 loc) · 2.23 KB
/
ngx_gridproxy_module.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Based on
* code by Francesco Giacomini <[email protected]>
* https://forum.nginx.org/read.php?29,283413,283421#msg-283421
* other modules from nginx
* With code updates by Brandon White <[email protected]>
* */
#include <ngx_core.h>
#include <ngx_config.h>
#include <ngx_http_ssl_module.h>
#include <ngx_event_openssl.h>
static ngx_int_t ngx_ssl_allow_proxy_certs(ngx_ssl_t* ssl);
static char* ngx_gridproxy_merge_srv_conf(ngx_conf_t* cf, void*, void*);
static ngx_http_module_t ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
NULL, /* init main configuration */
NULL, /* create server configuration */
ngx_gridproxy_merge_srv_conf, /* merge server configuration */
NULL, /* create location configuration*/
NULL /* merge location configuration*/
};
ngx_module_t ngx_gridproxy_module = {
NGX_MODULE_V1,
&ctx, /* module context */
NULL, /* module directives */
NGX_HTTP_MODULE, /* module type */
NULL, /* init master */
NULL, /* init module */
NULL, /* init process */
NULL, /* init thread */
NULL, /* exit thread */
NULL, /* exit process */
NULL, /* exit master */
NGX_MODULE_V1_PADDING
};
static ngx_int_t ngx_ssl_allow_proxy_certs(ngx_ssl_t* ssl)
{
X509_STORE *store = SSL_CTX_get_cert_store(ssl->ctx);
if (store == NULL) {
ngx_ssl_error(NGX_LOG_EMERG,
ssl->log,
0,
"SSL_CTX_get_cert_store() failed");
return NGX_ERROR;
}
X509_STORE_set_flags(store, X509_V_FLAG_ALLOW_PROXY_CERTS);
return NGX_OK;
}
static char* ngx_gridproxy_merge_srv_conf(ngx_conf_t* cf, void* p1, void*p2)
{
ngx_http_ssl_srv_conf_t *conf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_ssl_module);
/* avoid unused */
int delta = (char *)p2 - (char*)p1;
delta = delta * 2;
if (conf->ssl.ctx != NULL) {
if (ngx_ssl_allow_proxy_certs(&conf->ssl) != NGX_OK) {
return NGX_CONF_ERROR;
}
}
return NGX_CONF_OK;
}