Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
ngx_http_voms_module
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cnafsd
ngx_http_voms_module
Commits
bdd5f835
There was a problem fetching the pipeline summary.
Commit
bdd5f835
authored
6 years ago
by
Francesco Giacomini
Browse files
Options
Downloads
Patches
Plain Diff
fix issue #14
parent
a7ad6f58
No related branches found
No related tags found
1 merge request
!8
add support for ssl_client_ee_s_dn and ssl_client_ee_i_dn
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ngx_http_voms_module.cpp
+20
-90
20 additions, 90 deletions
src/ngx_http_voms_module.cpp
with
20 additions
and
90 deletions
src/ngx_http_voms_module.cpp
+
20
−
90
View file @
bdd5f835
...
@@ -33,10 +33,7 @@ using X509Ptr = std::unique_ptr<X509, decltype(&X509_free)>;
...
@@ -33,10 +33,7 @@ using X509Ptr = std::unique_ptr<X509, decltype(&X509_free)>;
using
VomsAc
=
voms
;
using
VomsAc
=
voms
;
using
MaybeVomsAc
=
boost
::
optional
<
VomsAc
>
;
using
MaybeVomsAc
=
boost
::
optional
<
VomsAc
>
;
enum
EECSubjectOrIssuer
{
enum
class
EeDn
{
SUBJECT
,
ISSUER
};
SUBJECT
,
ISSUER
};
static
ngx_int_t
add_variables
(
ngx_conf_t
*
cf
);
static
ngx_int_t
add_variables
(
ngx_conf_t
*
cf
);
...
@@ -184,7 +181,7 @@ static ngx_http_variable_t variables[] = {
...
@@ -184,7 +181,7 @@ static ngx_http_variable_t variables[] = {
ngx_string
(
"ssl_client_ee_s_dn"
),
ngx_string
(
"ssl_client_ee_s_dn"
),
NULL
,
NULL
,
get_ssl_client_ee_dn
,
get_ssl_client_ee_dn
,
SUBJECT
,
static_cast
<
uintptr_t
>
(
EeDn
::
SUBJECT
)
,
NGX_HTTP_VAR_NOCACHEABLE
,
NGX_HTTP_VAR_NOCACHEABLE
,
0
//
0
//
},
},
...
@@ -192,7 +189,7 @@ static ngx_http_variable_t variables[] = {
...
@@ -192,7 +189,7 @@ static ngx_http_variable_t variables[] = {
ngx_string
(
"ssl_client_ee_i_dn"
),
ngx_string
(
"ssl_client_ee_i_dn"
),
NULL
,
NULL
,
get_ssl_client_ee_dn
,
get_ssl_client_ee_dn
,
ISSUER
,
static_cast
<
uintptr_t
>
(
EeDn
::
ISSUER
)
,
NGX_HTTP_VAR_NOCACHEABLE
,
NGX_HTTP_VAR_NOCACHEABLE
,
0
//
0
//
},
},
...
@@ -221,7 +218,7 @@ static std::string to_rfc2253(X509_NAME* name)
...
@@ -221,7 +218,7 @@ static std::string to_rfc2253(X509_NAME* name)
}
}
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L
uint32_t
X509_get_extension_flags
(
X509
*
x
)
static
uint32_t
X509_get_extension_flags
(
X509
*
x
)
{
{
return
x
->
ex_flags
;
return
x
->
ex_flags
;
}
}
...
@@ -233,10 +230,9 @@ static bool is_proxy(X509* cert)
...
@@ -233,10 +230,9 @@ static bool is_proxy(X509* cert)
}
}
static
ngx_int_t
get_ssl_client_ee_dn
(
ngx_http_request_t
*
r
,
static
ngx_int_t
get_ssl_client_ee_dn
(
ngx_http_request_t
*
r
,
ngx_http_variable_value_t
*
v
,
ngx_http_variable_value_t
*
v
,
uintptr_t
data
)
uintptr_t
data
)
{
{
ngx_log_error
(
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"%s"
,
__func__
);
ngx_log_error
(
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"%s"
,
__func__
);
v
->
not_found
=
1
;
v
->
not_found
=
1
;
...
@@ -248,7 +244,7 @@ static ngx_int_t get_ssl_client_ee_dn(ngx_http_request_t* r,
...
@@ -248,7 +244,7 @@ static ngx_int_t get_ssl_client_ee_dn(ngx_http_request_t* r,
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"SSL_get_peer_cert_chain() failed"
);
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"SSL_get_peer_cert_chain() failed"
);
return
NGX_OK
;
return
NGX_OK
;
}
}
X509
*
ee_cert
=
nullptr
;
X509
*
ee_cert
=
nullptr
;
if
(
sk_X509_num
(
chain
)
==
0
)
{
if
(
sk_X509_num
(
chain
)
==
0
)
{
...
@@ -272,90 +268,28 @@ static ngx_int_t get_ssl_client_ee_dn(ngx_http_request_t* r,
...
@@ -272,90 +268,28 @@ static ngx_int_t get_ssl_client_ee_dn(ngx_http_request_t* r,
return
NGX_OK
;
return
NGX_OK
;
}
}
X509_NAME
*
dn
=
nullptr
;
X509_NAME
*
dn
;
if
(
data
==
SUBJECT
)
{
switch
(
static_cast
<
EeDn
>
(
data
))
{
dn
=
X509_get_subject_name
(
ee_cert
);
case
EeDn
::
SUBJECT
:
}
else
{
dn
=
X509_get_subject_name
(
ee_cert
);
dn
=
X509_get_issuer_name
(
ee_cert
);
break
;
case
EeDn
::
ISSUER
:
dn
=
X509_get_issuer_name
(
ee_cert
);
break
;
default:
dn
=
nullptr
;
}
}
if
(
!
dn
)
{
if
(
!
dn
)
{
ngx_log_error
(
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"cannot get dn from certificate"
);
return
NGX_OK
;
}
std
::
string
value
=
to_rfc2253
(
dn
);
auto
buffer
=
static_cast
<
u_char
*>
(
ngx_pnalloc
(
r
->
pool
,
value
.
size
()));
if
(
!
buffer
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"ngx_pnalloc() failed"
);
return
NGX_OK
;
}
ngx_memcpy
(
buffer
,
value
.
c_str
(),
value
.
size
());
v
->
data
=
buffer
;
v
->
len
=
value
.
size
();
v
->
valid
=
1
;
v
->
not_found
=
0
;
v
->
no_cacheable
=
0
;
return
NGX_OK
;
}
static
ngx_int_t
get_ssl_client_ee_s_dn
(
ngx_http_request_t
*
r
,
ngx_http_variable_value_t
*
v
,
uintptr_t
data
)
{
ngx_log_error
(
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"%s"
,
__func__
);
v
->
not_found
=
1
;
v
->
valid
=
0
;
auto
chain
=
SSL_get_peer_cert_chain
(
r
->
connection
->
ssl
->
connection
);
if
(
!
chain
)
{
ngx_log_error
(
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"SSL_get_peer_cert_chain() failed"
);
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"cannot get DN from certificate"
);
return
NGX_OK
;
}
X509
*
ee_cert
=
nullptr
;
if
(
sk_X509_num
(
chain
)
==
0
)
{
ee_cert
=
SSL_get_peer_certificate
(
r
->
connection
->
ssl
->
connection
);
}
else
{
// find first non-proxy
for
(
int
i
=
0
;
i
!=
sk_X509_num
(
chain
);
++
i
)
{
auto
cert
=
sk_X509_value
(
chain
,
i
);
if
(
cert
&&
!
is_proxy
(
cert
))
{
ee_cert
=
cert
;
break
;
}
}
}
if
(
!
ee_cert
)
{
ngx_log_error
(
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"cannot identify end-entity certificate"
);
return
NGX_OK
;
}
auto
dn
=
X509_get_subject_name
(
ee_cert
);
if
(
!
dn
)
{
ngx_log_error
(
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"cannot get subject dn from certificate"
);
return
NGX_OK
;
return
NGX_OK
;
}
}
std
::
string
value
=
to_rfc2253
(
dn
);
std
::
string
value
=
to_rfc2253
(
dn
);
auto
buffer
=
static_cast
<
u_char
*>
(
ngx_pnalloc
(
r
->
pool
,
value
.
size
()));
auto
buffer
=
static_cast
<
u_char
*>
(
ngx_pnalloc
(
r
->
pool
,
value
.
size
()));
if
(
!
buffer
)
{
if
(
!
buffer
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"ngx_pnalloc() failed"
);
return
NGX_OK
;
return
NGX_OK
;
}
}
ngx_memcpy
(
buffer
,
value
.
c_str
(),
value
.
size
());
ngx_memcpy
(
buffer
,
value
.
c_str
(),
value
.
size
());
...
@@ -389,10 +323,7 @@ static MaybeVomsAc retrieve_voms_ac_from_proxy(ngx_http_request_t* r)
...
@@ -389,10 +323,7 @@ static MaybeVomsAc retrieve_voms_ac_from_proxy(ngx_http_request_t* r)
ngx_log_error
(
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"%s"
,
__func__
);
ngx_log_error
(
NGX_LOG_DEBUG
,
r
->
connection
->
log
,
0
,
"%s"
,
__func__
);
if
(
!
r
->
http_connection
->
ssl
)
{
if
(
!
r
->
http_connection
->
ssl
)
{
ngx_log_error
(
NGX_LOG_ERR
,
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"SSL not enabled"
);
r
->
connection
->
log
,
0
,
"SSL not enabled"
);
return
boost
::
none
;
return
boost
::
none
;
}
}
...
@@ -497,7 +428,6 @@ static ngx_int_t generic_getter(ngx_http_request_t* r,
...
@@ -497,7 +428,6 @@ static ngx_int_t generic_getter(ngx_http_request_t* r,
auto
buffer
=
static_cast
<
u_char
*>
(
ngx_pnalloc
(
r
->
pool
,
value
.
size
()));
auto
buffer
=
static_cast
<
u_char
*>
(
ngx_pnalloc
(
r
->
pool
,
value
.
size
()));
if
(
!
buffer
)
{
if
(
!
buffer
)
{
ngx_log_error
(
NGX_LOG_ERR
,
r
->
connection
->
log
,
0
,
"ngx_pnalloc() failed"
);
return
NGX_OK
;
return
NGX_OK
;
}
}
ngx_memcpy
(
buffer
,
value
.
c_str
(),
value
.
size
());
ngx_memcpy
(
buffer
,
value
.
c_str
(),
value
.
size
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment