Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
2da2b91a
Commit
2da2b91a
authored
Jun 04, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have the SSL policy NOT own the socket by default
parent
25d12e95
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
1 deletion
+31
-1
libcaf_net/caf/net/ssl/context.hpp
libcaf_net/caf/net/ssl/context.hpp
+11
-0
libcaf_net/src/net/ssl/connection.cpp
libcaf_net/src/net/ssl/connection.cpp
+1
-1
libcaf_net/src/net/ssl/context.cpp
libcaf_net/src/net/ssl/context.cpp
+15
-0
libcaf_net/src/net/ssl/transport.cpp
libcaf_net/src/net/ssl/transport.cpp
+4
-0
No files found.
libcaf_net/caf/net/ssl/context.hpp
View file @
2da2b91a
...
...
@@ -13,6 +13,10 @@
namespace
caf
::
net
::
ssl
{
struct
close_on_shutdown_t
{};
constexpr
close_on_shutdown_t
close_on_shutdown
=
close_on_shutdown_t
{};
/// SSL state, shared by multiple connections.
class
CAF_NET_EXPORT
context
{
public:
...
...
@@ -71,8 +75,15 @@ public:
// -- connections ------------------------------------------------------------
/// Creates a new SSL connection on `fd`. The connection does not take
/// ownership of the socket, i.e., does not close the socket when the SSL
/// session ends.
expected
<
connection
>
new_connection
(
stream_socket
fd
);
/// Creates a new SSL connection on `fd`. The connection takes ownership of
/// the socket, i.e., closes the socket when the SSL session ends.
expected
<
connection
>
new_connection
(
stream_socket
fd
,
close_on_shutdown_t
);
// -- certificates and keys --------------------------------------------------
/// Configure the context to use the default locations for loading CA
...
...
libcaf_net/src/net/ssl/connection.cpp
View file @
2da2b91a
...
...
@@ -132,7 +132,7 @@ size_t connection::buffered() const noexcept {
}
stream_socket
connection
::
fd
()
const
noexcept
{
if
(
auto
id
=
SSL_get_fd
(
native
(
pimpl_
)))
if
(
auto
id
=
SSL_get_fd
(
native
(
pimpl_
))
;
id
!=
-
1
)
return
stream_socket
{
static_cast
<
socket_id
>
(
id
)};
else
return
stream_socket
{
invalid_socket_id
};
...
...
libcaf_net/src/net/ssl/context.cpp
View file @
2da2b91a
...
...
@@ -183,6 +183,21 @@ bool context::has_last_error() noexcept {
// -- connections --------------------------------------------------------------
expected
<
connection
>
context
::
new_connection
(
stream_socket
fd
)
{
if
(
auto
ptr
=
SSL_new
(
native
(
pimpl_
)))
{
auto
conn
=
connection
::
from_native
(
ptr
);
if
(
auto
bio_ptr
=
BIO_new_socket
(
fd
.
id
,
BIO_NOCLOSE
))
{
SSL_set_bio
(
ptr
,
bio_ptr
,
bio_ptr
);
return
{
std
::
move
(
conn
)};
}
else
{
return
{
make_error
(
sec
::
logic_error
,
"BIO_new_socket failed"
)};
}
}
else
{
return
{
make_error
(
sec
::
logic_error
,
"SSL_new returned null"
)};
}
}
expected
<
connection
>
context
::
new_connection
(
stream_socket
fd
,
close_on_shutdown_t
)
{
if
(
auto
ptr
=
SSL_new
(
native
(
pimpl_
)))
{
auto
conn
=
connection
::
from_native
(
ptr
);
if
(
SSL_set_fd
(
ptr
,
fd
.
id
)
==
1
)
...
...
libcaf_net/src/net/ssl/transport.cpp
View file @
2da2b91a
...
...
@@ -42,6 +42,10 @@ public:
return
caf
::
none
;
}
socket
handle
()
const
override
{
return
policy_
.
conn
.
fd
();
}
void
handle_read_event
()
override
{
if
(
auto
res
=
advance_handshake
();
res
>
0
)
{
owner_
->
deregister
();
...
...
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