CppServer
1.0.5.0
C++ Server Library
Loading...
Searching...
No Matches
source
server
asio
ssl_context.cpp
Go to the documentation of this file.
1
9
#include "
server/asio/ssl_context.h
"
10
11
#if defined(_WIN32) || defined(_WIN64)
12
#include <wincrypt.h>
13
#endif
14
15
namespace
CppServer
{
16
namespace
Asio {
17
18
void
SSLContext::set_root_certs
()
19
{
20
#if defined(_WIN32) || defined(_WIN64)
21
HCERTSTORE
hStore
=
CertOpenSystemStore
(0,
"ROOT"
);
22
if
(
hStore
==
nullptr
)
23
return
;
24
25
X509_STORE
*
store
=
X509_STORE_new
();
26
PCCERT_CONTEXT
pContext
=
nullptr
;
27
while
((
pContext
=
CertEnumCertificatesInStore
(
hStore
,
pContext
)) !=
nullptr
)
28
{
29
// Convert from DER to internal format
30
X509
*
x509
=
d2i_X509
(
nullptr
, (
const
unsigned
char
**)&
pContext
->pbCertEncoded,
pContext
->cbCertEncoded);
31
if
(
x509
!=
nullptr
)
32
{
33
X509_STORE_add_cert
(
store
,
x509
);
34
X509_free
(
x509
);
35
}
36
}
37
38
CertFreeCertificateContext
(
pContext
);
39
CertCloseStore
(
hStore
, 0);
40
41
// Attach X509_STORE to the current SSL context
42
SSL_CTX_set_cert_store
(
native_handle
(),
store
);
43
#endif
44
}
45
46
}
// namespace Asio
47
}
// namespace CppServer
CppServer::Asio::AllocateHandler
Asio allocate handler wrapper.
Definition
memory.h:133
CppServer::Asio::SSLContext::set_root_certs
void set_root_certs()
Configures the context to use system root certificates.
Definition
ssl_context.cpp:18
CppServer
C++ Server project definitions.
Definition
asio.h:56
ssl_context.h
SSL context definition.
Generated by
1.9.8