SSL stuff working on windows again, excepting win CA registry
This commit is contained in:
@@ -28,19 +28,13 @@
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/pem.h>
|
||||
|
||||
#define CHBUF_SIZE (256*1024)
|
||||
#define POLLVEC_SIZE (DrivenEngine::MAX_CHAN+1)
|
||||
|
||||
static std::unique_ptr<char[]> chbuf;
|
||||
static std::unique_ptr<struct pollfd[]> pollvec;
|
||||
|
||||
static void set_nonblocking(SOCKET sock) {
|
||||
u_long mode = 1; // 1 to enable non-blocking socket
|
||||
int status = ioctlsocket(sock, FIONBIO, &mode);
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
static std::string winsock_error_string(int errcode) {
|
||||
static std::string strerror_str(int errcode) {
|
||||
std::ostringstream oss;
|
||||
oss << "error " << errcode;
|
||||
return oss.str();
|
||||
@@ -55,17 +49,15 @@ static PADDRINFOA find_good_addr(PADDRINFOA addrinfo) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static SOCKET open_connection(std::string_view target, std::string &err) {
|
||||
static SOCKET open_connection(const char *host, const char *port, std::string &err) {
|
||||
PADDRINFOA addrs = nullptr;
|
||||
PADDRINFOA goodaddr = nullptr;
|
||||
SOCKET sock = INVALID_SOCKET;
|
||||
std::string host, port;
|
||||
|
||||
err.clear();
|
||||
drv::split_host_port(target, host, port);
|
||||
int status = getaddrinfo(host.data(), port.data(), nullptr, &addrs);
|
||||
int status = getaddrinfo(host, port, nullptr, &addrs);
|
||||
while (status == WSATRY_AGAIN) {
|
||||
status = getaddrinfo(host.data(), port.data(), nullptr, &addrs);
|
||||
status = getaddrinfo(host, port, nullptr, &addrs);
|
||||
}
|
||||
if (status == WSAHOST_NOT_FOUND) {
|
||||
err = "host not found";
|
||||
@@ -194,7 +186,7 @@ static int socket_close(SOCKET socket) {
|
||||
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, std::string &err) {
|
||||
int status = WSAPoll(pollvec, pollcount, mstimeout);
|
||||
if (status < 0) {
|
||||
err = winsock_error_string(WSAGetLastError());
|
||||
err = strerror_str(WSAGetLastError());
|
||||
return -1;
|
||||
}
|
||||
return status;
|
||||
@@ -243,7 +235,23 @@ static int console_read(char *bytes, int nbytes) {
|
||||
}
|
||||
}
|
||||
|
||||
void driver_sysinit(int argc, char *argv[]) {
|
||||
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);
|
||||
SSL_CTX_set_verify(ctx, verify, nullptr);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
class MonoClock {
|
||||
|
||||
Reference in New Issue
Block a user