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
3f9eb1e5
Commit
3f9eb1e5
authored
May 17, 2012
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ssl: add support for certificates issues to an IP address
parent
d3e1367f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
7 deletions
+32
-7
src/netops.c
+32
-7
No files found.
src/netops.c
View file @
3f9eb1e5
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#endif
#endif
#include <ctype.h>
#include <ctype.h>
#include <arpa/inet.h>
#include "git2/errors.h"
#include "git2/errors.h"
#include "common.h"
#include "common.h"
...
@@ -219,8 +220,23 @@ static int verify_server_cert(git_transport *t, const char *host)
...
@@ -219,8 +220,23 @@ static int verify_server_cert(git_transport *t, const char *host)
X509
*
cert
;
X509
*
cert
;
X509_NAME
*
peer_name
;
X509_NAME
*
peer_name
;
char
buf
[
1024
];
char
buf
[
1024
];
int
matched
=
-
1
;
int
matched
=
-
1
,
type
=
GEN_DNS
;
GENERAL_NAMES
*
alts
;
GENERAL_NAMES
*
alts
;
struct
in6_addr
addr6
;
struct
in_addr
addr4
;
void
*
addr
;
/* Try to parse the host as an IP address to see if it is */
if
(
inet_pton
(
AF_INET
,
host
,
&
addr4
))
{
type
=
GEN_IPADD
;
addr
=
&
addr4
;
}
else
{
if
(
inet_pton
(
AF_INET6
,
host
,
&
addr6
))
{
type
=
GEN_IPADD
;
addr
=
&
addr6
;
}
}
cert
=
SSL_get_peer_certificate
(
t
->
ssl
.
ssl
);
cert
=
SSL_get_peer_certificate
(
t
->
ssl
.
ssl
);
...
@@ -235,14 +251,23 @@ static int verify_server_cert(git_transport *t, const char *host)
...
@@ -235,14 +251,23 @@ static int verify_server_cert(git_transport *t, const char *host)
const
char
*
name
=
(
char
*
)
ASN1_STRING_data
(
gn
->
d
.
ia5
);
const
char
*
name
=
(
char
*
)
ASN1_STRING_data
(
gn
->
d
.
ia5
);
size_t
namelen
=
(
size_t
)
ASN1_STRING_length
(
gn
->
d
.
ia5
);
size_t
namelen
=
(
size_t
)
ASN1_STRING_length
(
gn
->
d
.
ia5
);
/*
If it contains embedded NULs, don't even try
*/
/*
Skip any names of a type we're not looking for
*/
if
(
namelen
!=
strnlen
(
name
,
namelen
)
)
if
(
gn
->
type
!=
type
)
continue
;
continue
;
if
(
check_host_name
(
name
,
host
)
<
0
)
if
(
type
==
GEN_DNS
)
{
matched
=
0
;
/* If it contains embedded NULs, don't even try */
else
if
(
namelen
!=
strnlen
(
name
,
namelen
))
matched
=
1
;
continue
;
if
(
check_host_name
(
name
,
host
)
<
0
)
matched
=
0
;
else
matched
=
1
;
}
else
if
(
type
==
GEN_IPADD
)
{
/* Here name isn't so much a name but a binary representation of the IP */
matched
=
!!
memcmp
(
name
,
addr
,
namelen
);
}
}
}
}
}
GENERAL_NAMES_free
(
alts
);
GENERAL_NAMES_free
(
alts
);
...
...
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