Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
2518eb81
Commit
2518eb81
authored
Nov 24, 2017
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openssl: merge all the exit paths of verify_server_cert
This makes it easier to cleanup allocated resources on exit.
parent
2482559d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
src/streams/openssl.c
+15
-11
No files found.
src/streams/openssl.c
View file @
2518eb81
...
...
@@ -341,7 +341,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
struct
in6_addr
addr6
;
struct
in_addr
addr4
;
void
*
addr
;
int
i
=
-
1
,
j
;
int
i
=
-
1
,
j
,
error
=
0
;
if
(
SSL_get_verify_result
(
ssl
)
!=
X509_V_OK
)
{
giterr_set
(
GITERR_SSL
,
"the SSL certificate is invalid"
);
...
...
@@ -362,8 +362,9 @@ static int verify_server_cert(SSL *ssl, const char *host)
cert
=
SSL_get_peer_certificate
(
ssl
);
if
(
!
cert
)
{
error
=
-
1
;
giterr_set
(
GITERR_SSL
,
"the server did not provide a certificate"
);
return
-
1
;
goto
cleanup
;
}
/* Check the alternative names */
...
...
@@ -401,8 +402,9 @@ static int verify_server_cert(SSL *ssl, const char *host)
if
(
matched
==
0
)
goto
cert_fail_name
;
if
(
matched
==
1
)
return
0
;
if
(
matched
==
1
)
{
goto
cleanup
;
}
/* If no alternative names are available, check the common name */
peer_name
=
X509_get_subject_name
(
cert
);
...
...
@@ -444,18 +446,20 @@ static int verify_server_cert(SSL *ssl, const char *host)
if
(
check_host_name
((
char
*
)
peer_cn
,
host
)
<
0
)
goto
cert_fail_name
;
OPENSSL_free
(
peer_cn
)
;
goto
cleanup
;
return
0
;
cert_fail_name:
error
=
GIT_ECERTIFICATE
;
giterr_set
(
GITERR_SSL
,
"hostname does not match certificate"
);
goto
cleanup
;
on_error:
OPENSSL_free
(
peer_cn
);
return
ssl_set_error
(
ssl
,
0
)
;
error
=
ssl_set_error
(
ssl
,
0
);
goto
cleanup
;
c
ert_fail_name
:
c
leanup
:
OPENSSL_free
(
peer_cn
);
giterr_set
(
GITERR_SSL
,
"hostname does not match certificate"
);
return
GIT_ECERTIFICATE
;
return
error
;
}
typedef
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment