Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
tci-gateway-module
Grpc
Commits
3a0e41c2
Commit
3a0e41c2
authored
10 years ago
by
jboeuf
Browse files
Options
Downloads
Plain Diff
Merge pull request #801 from ctiller/sec-wtf
Strip port in peer name check
parents
ad601775
deb49dd1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/security/security_context.c
+21
-2
21 additions, 2 deletions
src/core/security/security_context.c
test/core/end2end/tests/simple_request.c
+2
-2
2 additions, 2 deletions
test/core/end2end/tests/simple_request.c
with
23 additions
and
4 deletions
src/core/security/security_context.c
+
21
−
2
View file @
3a0e41c2
...
...
@@ -338,6 +338,24 @@ static grpc_security_status ssl_server_create_handshaker(
return
ssl_create_handshaker
(
c
->
handshaker_factory
,
0
,
NULL
,
handshaker
);
}
static
int
ssl_host_matches_name
(
const
tsi_peer
*
peer
,
const
char
*
peer_name
)
{
char
*
allocated_name
=
NULL
;
int
r
;
if
(
strchr
(
peer_name
,
':'
)
!=
NULL
)
{
char
*
ignored_port
;
gpr_split_host_port
(
peer_name
,
&
allocated_name
,
&
ignored_port
);
gpr_free
(
ignored_port
);
peer_name
=
allocated_name
;
if
(
!
peer_name
)
return
0
;
}
r
=
tsi_ssl_peer_matches_name
(
peer
,
peer_name
);
gpr_free
(
allocated_name
);
return
r
;
}
static
grpc_security_status
ssl_check_peer
(
const
char
*
peer_name
,
const
tsi_peer
*
peer
)
{
/* Check the ALPN. */
...
...
@@ -359,10 +377,11 @@ static grpc_security_status ssl_check_peer(const char *peer_name,
/* Check the peer name if specified. */
if
(
peer_name
!=
NULL
&&
!
tsi_ssl_peer
_matches_name
(
peer
,
peer_name
))
{
!
ssl_host
_matches_name
(
peer
,
peer_name
))
{
gpr_log
(
GPR_ERROR
,
"Peer name %s is not in peer certificate"
,
peer_name
);
return
GRPC_SECURITY_ERROR
;
}
return
GRPC_SECURITY_OK
;
}
...
...
@@ -398,7 +417,7 @@ static grpc_security_status ssl_channel_check_call_host(
grpc_ssl_channel_security_context
*
c
=
(
grpc_ssl_channel_security_context
*
)
ctx
;
if
(
tsi_ssl_peer
_matches_name
(
&
c
->
peer
,
host
))
return
GRPC_SECURITY_OK
;
if
(
ssl_host
_matches_name
(
&
c
->
peer
,
host
))
return
GRPC_SECURITY_OK
;
/* If the target name was overridden, then the original target_name was
'checked' transitively during the previous peer check at the end of the
...
...
This diff is collapsed.
Click to expand it.
test/core/end2end/tests/simple_request.c
+
2
−
2
View file @
3a0e41c2
...
...
@@ -122,7 +122,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
int
was_cancelled
=
2
;
c
=
grpc_channel_create_call
(
f
.
client
,
f
.
client_cq
,
"/foo"
,
"foo.test.google.fr"
,
deadline
);
"foo.test.google.fr
:1234
"
,
deadline
);
GPR_ASSERT
(
c
);
grpc_metadata_array_init
(
&
initial_metadata_recv
);
...
...
@@ -178,7 +178,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
GPR_ASSERT
(
status
==
GRPC_STATUS_UNIMPLEMENTED
);
GPR_ASSERT
(
0
==
strcmp
(
details
,
"xyz"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
method
,
"/foo"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
host
,
"foo.test.google.fr"
));
GPR_ASSERT
(
0
==
strcmp
(
call_details
.
host
,
"foo.test.google.fr
:1234
"
));
GPR_ASSERT
(
was_cancelled
==
0
);
gpr_free
(
details
);
...
...
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