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:
		
				
					committed by
					
						 Benjamin Sergeant
						Benjamin Sergeant
					
				
			
			
				
	
			
			
			
						parent
						
							7e521e38ef
						
					
				
				
					commit
					1a47656ba0
				
			| @@ -158,7 +158,7 @@ if (APPLE AND USE_TLS AND NOT USE_MBED_TLS AND NOT USE_OPEN_SSL) | |||||||
| endif() | endif() | ||||||
|  |  | ||||||
| if (WIN32) | if (WIN32) | ||||||
|   target_link_libraries(ixwebsocket wsock32 ws2_32) |   target_link_libraries(ixwebsocket wsock32 ws2_32 shlwapi) | ||||||
|   add_definitions(-D_CRT_SECURE_NO_WARNINGS) |   add_definitions(-D_CRT_SECURE_NO_WARNINGS) | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
| @@ -175,7 +175,9 @@ if (USE_TLS AND USE_OPEN_SSL) | |||||||
|     set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /usr/local/opt/openssl/include) |     set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /usr/local/opt/openssl/include) | ||||||
|   endif() |   endif() | ||||||
|  |  | ||||||
|  |   if(NOT OPENSSL_FOUND) | ||||||
|     find_package(OpenSSL REQUIRED) |     find_package(OpenSSL REQUIRED) | ||||||
|  |   endif() | ||||||
|   add_definitions(${OPENSSL_DEFINITIONS}) |   add_definitions(${OPENSSL_DEFINITIONS}) | ||||||
|   message(STATUS "OpenSSL: " ${OPENSSL_VERSION}) |   message(STATUS "OpenSSL: " ${OPENSSL_VERSION}) | ||||||
|   include_directories(${OPENSSL_INCLUDE_DIR}) |   include_directories(${OPENSSL_INCLUDE_DIR}) | ||||||
|   | |||||||
| @@ -10,12 +10,12 @@ | |||||||
|  |  | ||||||
| #ifdef IXWEBSOCKET_USE_MBED_TLS | #ifdef IXWEBSOCKET_USE_MBED_TLS | ||||||
| #include "IXSocketMbedTLS.h" | #include "IXSocketMbedTLS.h" | ||||||
| #elif defined(_WIN32) |  | ||||||
| #include "IXSocketSChannel.h" |  | ||||||
| #elif defined(IXWEBSOCKET_USE_OPEN_SSL) | #elif defined(IXWEBSOCKET_USE_OPEN_SSL) | ||||||
| #include "IXSocketOpenSSL.h" | #include "IXSocketOpenSSL.h" | ||||||
| #elif __APPLE__ | #elif __APPLE__ | ||||||
| #include "IXSocketAppleSSL.h" | #include "IXSocketAppleSSL.h" | ||||||
|  | #elif defined(_WIN32) | ||||||
|  | #include "IXSocketSChannel.h" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #else | #else | ||||||
|   | |||||||
| @@ -11,8 +11,14 @@ | |||||||
| #include "IXSocketConnect.h" | #include "IXSocketConnect.h" | ||||||
| #include <cassert> | #include <cassert> | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
|  | #ifdef _WIN32 | ||||||
|  | #include <Shlwapi.h> | ||||||
|  | #else | ||||||
| #include <fnmatch.h> | #include <fnmatch.h> | ||||||
|  | #endif | ||||||
|  | #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||||||
| #include <openssl/x509v3.h> | #include <openssl/x509v3.h> | ||||||
|  | #endif | ||||||
| #define socketerrno errno | #define socketerrno errno | ||||||
|  |  | ||||||
| namespace ix | namespace ix | ||||||
| @@ -136,7 +142,11 @@ namespace ix | |||||||
|      */ |      */ | ||||||
|     bool SocketOpenSSL::checkHost(const std::string& host, const char* pattern) |     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; |         return fnmatch(pattern, host.c_str(), 0) != FNM_NOMATCH; | ||||||
|  | #endif | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     bool SocketOpenSSL::openSSLCheckServerCert(SSL* ssl, |     bool SocketOpenSSL::openSSLCheckServerCert(SSL* ssl, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user