| 1 | // |
| 2 | // NetSSL.h |
| 3 | // |
| 4 | // Library: NetSSL_OpenSSL |
| 5 | // Package: SSLCore |
| 6 | // Module: OpenSSL |
| 7 | // |
| 8 | // Basic definitions for the Poco OpenSSL library. |
| 9 | // This file must be the first file included by every other OpenSSL |
| 10 | // header file. |
| 11 | // |
| 12 | // Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. |
| 13 | // and Contributors. |
| 14 | // |
| 15 | // SPDX-License-Identifier: BSL-1.0 |
| 16 | // |
| 17 | |
| 18 | |
| 19 | #ifndef NetSSL_NetSSL_INCLUDED |
| 20 | #define NetSSL_NetSSL_INCLUDED |
| 21 | |
| 22 | |
| 23 | #include "Poco/Net/Net.h" |
| 24 | #include "Poco/Crypto/Crypto.h" |
| 25 | |
| 26 | // |
| 27 | // The following block is the standard way of creating macros which make exporting |
| 28 | // from a DLL simpler. All files within this DLL are compiled with the NetSSL_EXPORTS |
| 29 | // symbol defined on the command line. this symbol should not be defined on any project |
| 30 | // that uses this DLL. This way any other project whose source files include this file see |
| 31 | // NetSSL_API functions as being imported from a DLL, whereas this DLL sees symbols |
| 32 | // defined with this macro as being exported. |
| 33 | // |
| 34 | #if defined(POCO_COMPILER_MSVC) && defined(POCO_DLL) |
| 35 | #if defined(NetSSL_EXPORTS) |
| 36 | #define NetSSL_API __declspec(dllexport) |
| 37 | #else |
| 38 | #define NetSSL_API __declspec(dllimport) |
| 39 | #endif |
| 40 | #endif |
| 41 | |
| 42 | |
| 43 | #if !defined(NetSSL_API) |
| 44 | #if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4) |
| 45 | #define NetSSL_API __attribute__ ((visibility ("default"))) |
| 46 | #else |
| 47 | #define NetSSL_API |
| 48 | #endif |
| 49 | #endif |
| 50 | |
| 51 | |
| 52 | // |
| 53 | // Automatically link NetSSL |
| 54 | // |
| 55 | #if defined(POCO_COMPILER_MSVC) |
| 56 | #if !defined(POCO_NO_AUTOMATIC_LIBS) |
| 57 | #if defined(POCO_INTERNAL_OPENSSL_MSVC_VER) |
| 58 | #if defined(POCO_EXTERNAL_OPENSSL) |
| 59 | #pragma warning "External OpenSSL defined but internal headers used - possible mismatch!" |
| 60 | #endif // POCO_EXTERNAL_OPENSSL |
| 61 | #if !defined(_DEBUG) |
| 62 | #define POCO_DEBUG_SUFFIX "" |
| 63 | #if !defined (_DLL) |
| 64 | #define POCO_STATIC_SUFFIX "mt" |
| 65 | #else // _DLL |
| 66 | #define POCO_STATIC_SUFFIX "" |
| 67 | #endif |
| 68 | #else // _DEBUG |
| 69 | #define POCO_DEBUG_SUFFIX "d" |
| 70 | #if !defined (_DLL) |
| 71 | #define POCO_STATIC_SUFFIX "mt" |
| 72 | #else // _DLL |
| 73 | #define POCO_STATIC_SUFFIX "" |
| 74 | #endif |
| 75 | #endif |
| 76 | #pragma comment(lib, "libcrypto" POCO_STATIC_SUFFIX POCO_DEBUG_SUFFIX ".lib") |
| 77 | #pragma comment(lib, "libssl" POCO_STATIC_SUFFIX POCO_DEBUG_SUFFIX ".lib") |
| 78 | #if !defined(_WIN64) && !defined (_DLL) && \ |
| 79 | (POCO_INTERNAL_OPENSSL_MSVC_VER == 120) && \ |
| 80 | (POCO_MSVC_VERSION < POCO_INTERNAL_OPENSSL_MSVC_VER) |
| 81 | #pragma comment(lib, "libPreVS2013CRT" POCO_STATIC_SUFFIX POCO_DEBUG_SUFFIX ".lib") |
| 82 | #endif |
| 83 | #if !defined (_DLL) && (POCO_MSVS_VERSION >= 2015) |
| 84 | #pragma comment(lib, "legacy_stdio_definitions.lib") |
| 85 | #pragma comment(lib, "legacy_stdio_wide_specifiers.lib") |
| 86 | #endif |
| 87 | #endif // POCO_INTERNAL_OPENSSL_MSVC_VER |
| 88 | #if !defined(NetSSL_EXPORTS) |
| 89 | #pragma comment(lib, "PocoNetSSL" POCO_LIB_SUFFIX) |
| 90 | #endif |
| 91 | #endif // POCO_NO_AUTOMATIC_LIBS |
| 92 | #endif |
| 93 | |
| 94 | |
| 95 | namespace Poco { |
| 96 | namespace Net { |
| 97 | |
| 98 | |
| 99 | void NetSSL_API initializeSSL(); |
| 100 | /// Initialize the NetSSL library, as well as the underlying OpenSSL |
| 101 | /// libraries, by calling Poco::Crypto::OpenSSLInitializer::initialize(). |
| 102 | /// |
| 103 | /// Should be called before using any class from the NetSSL library. |
| 104 | /// The NetSSL will be initialized automatically, through |
| 105 | /// Poco::Crypto::OpenSSLInitializer instances or similar mechanisms |
| 106 | /// when creating Context or SSLManager instances. |
| 107 | /// However, it is recommended to call initializeSSL() |
| 108 | /// in any case at application startup. |
| 109 | /// |
| 110 | /// Can be called multiple times; however, for every call to |
| 111 | /// initializeSSL(), a matching call to uninitializeSSL() |
| 112 | /// must be performed. |
| 113 | |
| 114 | |
| 115 | void NetSSL_API uninitializeSSL(); |
| 116 | /// Uninitializes the NetSSL library by calling |
| 117 | /// Poco::Crypto::OpenSSLInitializer::uninitialize() and |
| 118 | /// shutting down the SSLManager. |
| 119 | |
| 120 | |
| 121 | } } // namespace Poco::Net |
| 122 | |
| 123 | |
| 124 | #endif // NetSSL_NetSSL_INCLUDED |
| 125 | |