Commit f4c9e7d2 authored by Orvid King's avatar Orvid King Committed by Facebook Github Bot

NetworkSocket support for OpenSSLUtils

Summary: More support means more diffs, as many small ones as possible.

Reviewed By: yfeldblum

Differential Revision: D12818383

fbshipit-source-id: be364e01d8d6d7b7419a2fc870c93dafcba5d2b1
parent f5cc18a3
...@@ -301,15 +301,14 @@ int OpenSSLUtils::getBioFd(BIO* b, int* fd) { ...@@ -301,15 +301,14 @@ int OpenSSLUtils::getBioFd(BIO* b, int* fd) {
#endif #endif
} }
void OpenSSLUtils::setBioFd(BIO* b, int fd, int flags) { void OpenSSLUtils::setBioFd(BIO* b, NetworkSocket fd, int flags) {
#ifdef _WIN32 #ifdef _WIN32
SOCKET socket = portability::sockets::fd_to_socket(fd);
// Internally OpenSSL uses this as an int for reasons completely // Internally OpenSSL uses this as an int for reasons completely
// beyond any form of sanity, so we do the cast ourselves to avoid // beyond any form of sanity, so we do the cast ourselves to avoid
// the warnings that would be generated. // the warnings that would be generated.
int sock = int(socket); int sock = int(fd.data);
#else #else
int sock = fd; int sock = fd.toFd();
#endif #endif
BIO_set_fd(b, sock, flags); BIO_set_fd(b, sock, flags);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#pragma once #pragma once
#include <folly/Range.h> #include <folly/Range.h>
#include <folly/net/NetworkSocket.h>
#include <folly/portability/OpenSSL.h> #include <folly/portability/OpenSSL.h>
#include <folly/portability/Sockets.h> #include <folly/portability/Sockets.h>
#include <folly/ssl/OpenSSLPtrTypes.h> #include <folly/ssl/OpenSSLPtrTypes.h>
...@@ -124,7 +125,10 @@ class OpenSSLUtils { ...@@ -124,7 +125,10 @@ class OpenSSLUtils {
static void setBioAppData(BIO* b, void* ptr); static void setBioAppData(BIO* b, void* ptr);
static void* getBioAppData(BIO* b); static void* getBioAppData(BIO* b);
static int getBioFd(BIO* b, int* fd); static int getBioFd(BIO* b, int* fd);
static void setBioFd(BIO* b, int fd, int flags); static void setBioFd(BIO* b, NetworkSocket fd, int flags);
static void setBioFd(BIO* b, int fd, int flags) {
setBioFd(b, NetworkSocket::fromFd(fd), flags);
}
}; };
} // namespace ssl } // namespace ssl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment