Code to load SSL certs from dir, and ssl overhaul
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
#include "wrap-vector.hpp"
|
||||
|
||||
#include "driver-util.hpp"
|
||||
#include "driver-ssl.hpp"
|
||||
#include "drivenengine.hpp"
|
||||
#include "dummycert.hpp"
|
||||
#include "util.hpp"
|
||||
#include "source.hpp"
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <synchapi.h>
|
||||
@@ -34,7 +35,7 @@ static void set_nonblocking(SOCKET sock) {
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
static std::string strerror_str(int errcode) {
|
||||
std::string strerror_str(int errcode) {
|
||||
std::ostringstream oss;
|
||||
oss << "error " << errcode;
|
||||
return oss.str();
|
||||
@@ -239,7 +240,7 @@ static int console_read(char *bytes, int nbytes) {
|
||||
}
|
||||
}
|
||||
|
||||
static void load_root_certs(SSL_CTX *ctx) {
|
||||
static void ssl_load_certificate_authorities(SSL_CTX *ctx) {
|
||||
HCERTSTORE hStore = CertOpenSystemStoreW(0, L"ROOT");
|
||||
PCCERT_CONTEXT pContext = NULL;
|
||||
X509 *x509;
|
||||
@@ -262,26 +263,6 @@ static void load_root_certs(SSL_CTX *ctx) {
|
||||
CertCloseStore(hStore, 0);
|
||||
}
|
||||
|
||||
static void ssl_ctx_use_dummycert(SSL_CTX *ctx);
|
||||
|
||||
static SSL_CTX *new_ssl_server_context() {
|
||||
SSL_CTX *ctx = SSL_CTX_new(TLS_method());
|
||||
SSL_CTX_set_mode(ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
|
||||
SSL_CTX_set_mode(ctx, SSL_MODE_ENABLE_PARTIAL_WRITE);
|
||||
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, nullptr);
|
||||
ssl_ctx_use_dummycert(ctx);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static SSL_CTX *new_ssl_client_context(int verify) {
|
||||
SSL_CTX *ctx = SSL_CTX_new(TLS_method());
|
||||
SSL_CTX_set_mode(ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
|
||||
SSL_CTX_set_mode(ctx, SSL_MODE_ENABLE_PARTIAL_WRITE);
|
||||
if (verify == SSL_VERIFY_PEER) load_root_certs(ctx);
|
||||
SSL_CTX_set_verify(ctx, verify, nullptr);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
class MonoClock {
|
||||
public:
|
||||
double freq_;
|
||||
|
||||
Reference in New Issue
Block a user