Allow custom OpenSSL lib, only include openssl/x509v3.h when used. (#143)

* Allow custom OpenSSL lib, only include openssl/x509v3.h when used.

Using fnmatch on Unix systems, PathMatchSpecA is the best WINAPI equivalent.

* Moved shlwapi into WIN32 block.
This commit is contained in:
Matthew Albrecht
2020-01-08 15:57:57 -06:00
committed by Benjamin Sergeant
parent 7e521e38ef
commit 1a47656ba0
3 changed files with 16 additions and 4 deletions

View File

@ -10,12 +10,12 @@
#ifdef IXWEBSOCKET_USE_MBED_TLS
#include "IXSocketMbedTLS.h"
#elif defined(_WIN32)
#include "IXSocketSChannel.h"
#elif defined(IXWEBSOCKET_USE_OPEN_SSL)
#include "IXSocketOpenSSL.h"
#elif __APPLE__
#include "IXSocketAppleSSL.h"
#elif defined(_WIN32)
#include "IXSocketSChannel.h"
#endif
#else

View File

@ -11,8 +11,14 @@
#include "IXSocketConnect.h"
#include <cassert>
#include <errno.h>
#ifdef _WIN32
#include <Shlwapi.h>
#else
#include <fnmatch.h>
#endif
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#include <openssl/x509v3.h>
#endif
#define socketerrno errno
namespace ix
@ -136,7 +142,11 @@ namespace ix
*/
bool SocketOpenSSL::checkHost(const std::string& host, const char* pattern)
{
#ifdef _WIN32
return PathMatchSpecA(host.c_str(), pattern);
#else
return fnmatch(pattern, host.c_str(), 0) != FNM_NOMATCH;
#endif
}
bool SocketOpenSSL::openSSLCheckServerCert(SSL* ssl,