Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
732e9af4
Commit
732e9af4
authored
Jun 29, 2020
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
http: set SNI when using TLS
parent
4e5666fc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/http.cpp
+19
-19
19 additions, 19 deletions
src/http.cpp
with
19 additions
and
19 deletions
src/http.cpp
+
19
−
19
View file @
732e9af4
...
@@ -189,28 +189,28 @@ void
...
@@ -189,28 +189,28 @@ void
Connection
::
set_ssl_verification
(
const
std
::
string
&
hostname
,
const
asio
::
ssl
::
verify_mode
verify_mode
)
Connection
::
set_ssl_verification
(
const
std
::
string
&
hostname
,
const
asio
::
ssl
::
verify_mode
verify_mode
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
mutex_
);
if
(
ssl_socket_
and
verify_mode
!=
asio
::
ssl
::
verify_none
)
{
if
(
ssl_socket_
)
{
// Set SNI Hostname (many hosts need this to handshake successfully)
SSL_set_tlsext_host_name
(
ssl_socket_
->
asio_ssl_stream
().
native_handle
(),
hostname
.
c_str
());
ssl_socket_
->
asio_ssl_stream
().
set_verify_mode
(
verify_mode
);
ssl_socket_
->
asio_ssl_stream
().
set_verify_mode
(
verify_mode
);
if
(
verify_mode
!=
asio
::
ssl
::
verify_none
)
{
ssl_socket_
->
asio_ssl_stream
().
set_verify_callback
([
ssl_socket_
->
asio_ssl_stream
().
set_verify_callback
([
id
=
id_
,
logger
=
logger_
,
hostname
id
=
id_
,
logger
=
logger_
,
hostname
]
(
bool
preverified
,
asio
::
ssl
::
verify_context
&
ctx
)
->
bool
{
]
(
bool
preverified
,
asio
::
ssl
::
verify_context
&
ctx
)
->
bool
{
if
(
logger
)
if
(
logger
)
logger
->
d
(
"[connection:%i] verify %s compliance to RFC 2818"
,
id
,
hostname
.
c_str
());
logger
->
d
(
"[connection:%i] verify %s compliance to RFC 2818"
,
id
,
hostname
.
c_str
());
if
(
preverified
)
return
preverified
;
// starts from CA and goes down the presented chain
// starts from CA and goes down the presented chain
auto
verifier
=
asio
::
ssl
::
rfc2818_verification
(
hostname
);
auto
verifier
=
asio
::
ssl
::
rfc2818_verification
(
hostname
);
bool
verified
=
verifier
(
preverified
,
ctx
);
bool
verified
=
verifier
(
preverified
,
ctx
);
auto
verify_ec
=
X509_STORE_CTX_get_error
(
ctx
.
native_handle
());
auto
verify_ec
=
X509_STORE_CTX_get_error
(
ctx
.
native_handle
());
if
(
verify_ec
!=
0
/*X509_V_OK*/
and
logger
)
if
(
verify_ec
!=
0
/*X509_V_OK*/
and
logger
)
logger
->
e
(
"[http::connection:%i] ssl verification error=%i %d"
,
id
,
verify_ec
,
verified
);
logger
->
e
(
"[http::connection:%i] ssl verification error=%i %d"
,
id
,
verify_ec
,
verified
);
else
if
(
logger
)
logger
->
w
(
"ssl verification result: %d %d"
,
verify_ec
,
verified
);
return
verified
;
return
verified
;
}
}
);
);
}
}
}
}
}
asio
::
streambuf
&
asio
::
streambuf
&
Connection
::
input
()
Connection
::
input
()
...
...
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