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
26e77f1f
Commit
26e77f1f
authored
Mar 01, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the OpenSSL policy copyable
parent
80eadedb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
11 deletions
+28
-11
libcaf_net/caf/net/openssl_transport.hpp
libcaf_net/caf/net/openssl_transport.hpp
+28
-11
No files found.
libcaf_net/caf/net/openssl_transport.hpp
View file @
26e77f1f
...
...
@@ -36,35 +36,52 @@ CAF_POP_WARNINGS
// -- small wrappers to help working with OpenSSL ------------------------------
namespace
caf
::
net
::
openssl
{
namespace
caf
{
template
<
>
struct
intrusive_ptr_access
<
SSL_CTX
>
{
public:
static
void
add_ref
(
SSL_CTX
*
ptr
)
noexcept
{
SSL_CTX_up_ref
(
ptr
);
}
/// Dispatches to the proper OpenSSL `free` function for each OpenSSL type.
struct
deleter
{
void
operator
()(
SSL_CTX
*
ptr
)
const
{
static
void
release
(
SSL_CTX
*
ptr
)
noexcept
{
SSL_CTX_free
(
ptr
);
}
};
void
operator
()(
SSL
*
ptr
)
const
{
template
<
>
struct
intrusive_ptr_access
<
SSL
>
{
public:
static
void
add_ref
(
SSL
*
ptr
)
noexcept
{
SSL_up_ref
(
ptr
);
}
static
void
release
(
SSL
*
ptr
)
noexcept
{
SSL_free
(
ptr
);
}
};
}
// namespace caf
namespace
caf
::
net
::
openssl
{
/// A smart pointer to an `SSL_CTX` structure.
/// @note technically, SSL structures are reference counted and we could use
/// `intrusive_ptr` instead. However, we have no need for shared ownership
/// semantics here and use `unique_ptr` for simplicity.
using
ctx_ptr
=
std
::
unique_ptr
<
SSL_CTX
,
deleter
>
;
using
ctx_ptr
=
intrusive_ptr
<
SSL_CTX
>
;
/// A smart pointer to an `SSL` structure.
/// @note technically, SSL structures are reference counted and we could use
/// `intrusive_ptr` instead. However, we have no need for shared ownership
/// semantics here and use `unique_ptr` for simplicity.
using
conn_ptr
=
std
::
unique_ptr
<
SSL
,
deleter
>
;
using
conn_ptr
=
intrusive_ptr
<
SSL
>
;
/// Convenience function for creating an OpenSSL context for given method.
inline
ctx_ptr
make_ctx
(
const
SSL_METHOD
*
method
)
{
if
(
auto
ptr
=
SSL_CTX_new
(
method
))
return
ctx_ptr
{
ptr
};
return
ctx_ptr
{
ptr
,
false
};
else
CAF_RAISE_ERROR
(
"SSL_CTX_new failed"
);
}
...
...
@@ -110,7 +127,7 @@ inline error private_key_pem_file(const ctx_ptr& ctx, const std::string& path) {
/// Convenience function for creating a new SSL structure from given context.
inline
conn_ptr
make_conn
(
const
ctx_ptr
&
ctx
)
{
if
(
auto
ptr
=
SSL_new
(
ctx
.
get
()))
return
conn_ptr
{
ptr
};
return
conn_ptr
{
ptr
,
false
};
else
CAF_RAISE_ERROR
(
"SSL_new failed"
);
}
...
...
@@ -132,9 +149,9 @@ public:
policy
()
=
delete
;
policy
(
const
policy
&
)
=
de
lete
;
policy
(
const
policy
&
)
=
de
fault
;
policy
&
operator
=
(
const
policy
&
)
=
de
lete
;
policy
&
operator
=
(
const
policy
&
)
=
de
fault
;
policy
(
policy
&&
)
=
default
;
...
...
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