SChannelServerContext and Win32 compilation fixes
This commit is contained in:
parent
b4c48b5b0f
commit
ab24246593
14 changed files with 71 additions and 23 deletions
|
@ -6,8 +6,12 @@ set(CMAKE_MODULE_PATH "cmake_modules")
|
|||
set(cppunit_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(cppunit)
|
||||
|
||||
if (WIN32)
|
||||
ADD_SUBDIRECTORY(msvc-deps)
|
||||
else()
|
||||
set(sqlite3_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(sqlite3)
|
||||
endif()
|
||||
|
||||
set(mysql_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(mysql)
|
||||
|
@ -29,12 +33,14 @@ find_package(event)
|
|||
set(Swiften_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(Swiften REQUIRED)
|
||||
|
||||
if (NOT WIN32)
|
||||
set(openssl_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(openssl REQUIRED)
|
||||
endif()
|
||||
|
||||
set(Boost_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
if (WIN32)
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
endif()
|
||||
|
@ -56,8 +62,10 @@ find_package(event)
|
|||
set(pqxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(pqxx)
|
||||
|
||||
if (NOT WIN32)
|
||||
set(dbus_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(dbus)
|
||||
endif()
|
||||
|
||||
find_package(Doxygen)
|
||||
|
||||
|
@ -75,7 +83,10 @@ if (SPECTRUM_VERSION)
|
|||
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
|
||||
else (SPECTRUM_VERSION)
|
||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
||||
execute_process(COMMAND git "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" rev-parse --short HEAD
|
||||
if (NOT GIT_EXECUTABLE)
|
||||
set (GIT_EXECUTABLE git)
|
||||
endif()
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" rev-parse --short HEAD
|
||||
OUTPUT_VARIABLE GIT_REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
@ -94,8 +105,15 @@ if (SQLITE3_FOUND)
|
|||
include_directories(${SQLITE3_INCLUDE_DIR})
|
||||
message("SQLite3 : yes")
|
||||
else (SQLITE3_FOUND)
|
||||
if (WIN32)
|
||||
ADD_DEFINITIONS(-DWITH_SQLITE)
|
||||
include_directories(msvc-deps/sqlite3)
|
||||
set (SQLITE3_LIBRARIES "${CMAKE_SOURCE_DIR}/msvc-deps/sqlite3/sqlite3.lib")
|
||||
message("SQLite3 : bundled")
|
||||
else()
|
||||
set(SQLITE3_LIBRARIES "")
|
||||
message("SQLite3 : no")
|
||||
endif()
|
||||
endif (SQLITE3_FOUND)
|
||||
|
||||
if (MYSQL_FOUND)
|
||||
|
@ -148,15 +166,19 @@ if (PROTOBUF_FOUND)
|
|||
message("IRC plugin : no (install libCommuni and libprotobuf-dev)")
|
||||
endif()
|
||||
|
||||
if (NOT WIN32)
|
||||
message("Frotz plugin : yes")
|
||||
message("SMSTools3 plugin : yes")
|
||||
|
||||
else()
|
||||
message("Frotz plugin : no")
|
||||
message("SMSTools3 plugin : no")
|
||||
if(${LIBDBUSGLIB_FOUND})
|
||||
message("Skype plugin : yes")
|
||||
include_directories(${LIBDBUSGLIB_INCLUDE_DIRS})
|
||||
else()
|
||||
message("Skype plugin : no (install dbus-glib-devel)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
else()
|
||||
message("Network plugins : no (install libprotobuf-dev)")
|
||||
|
@ -169,11 +191,10 @@ endif()
|
|||
if (LOG4CXX_FOUND)
|
||||
message("Logging : yes")
|
||||
include_directories(${LOG4CXX_INCLUDE_DIR})
|
||||
else()
|
||||
message(FATAL_ERROR "Logging : no (install log4cxx-devel)")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
ADD_DEFINITIONS(-DLOG4CXX_STATIC)
|
||||
ADD_DEFINITIONS(-D_WIN32_WINNT=0x501)
|
||||
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
|
||||
endif()
|
||||
|
@ -209,7 +230,10 @@ include_directories(include)
|
|||
include_directories(${EVENT_INCLUDE_DIRS})
|
||||
include_directories(${SWIFTEN_INCLUDE_DIR})
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
|
||||
if (NOT WIN32)
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
ADD_SUBDIRECTORY(plugin)
|
||||
|
|
|
@ -7,11 +7,10 @@ if (PROTOBUF_FOUND)
|
|||
ADD_SUBDIRECTORY(libcommuni)
|
||||
endif()
|
||||
|
||||
ADD_SUBDIRECTORY(smstools3)
|
||||
|
||||
ADD_SUBDIRECTORY(template)
|
||||
|
||||
if (NOT WIN32)
|
||||
ADD_SUBDIRECTORY(smstools3)
|
||||
ADD_SUBDIRECTORY(frotz)
|
||||
if (${LIBDBUSGLIB_FOUND})
|
||||
ADD_SUBDIRECTORY(skype)
|
||||
|
|
|
@ -4,7 +4,11 @@ FILE(GLOB SRC *.c *.cpp)
|
|||
|
||||
ADD_EXECUTABLE(spectrum2_template_backend ${SRC})
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(spectrum2_template_backend transport pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(spectrum2_template_backend transport ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
|
||||
endif()
|
||||
|
||||
#INSTALL(TARGETS spectrum2_template_backend RUNTIME DESTINATION bin)
|
||||
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
// Swiften
|
||||
#include "Swiften/Swiften.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
// for signal handler
|
||||
#include "unistd.h"
|
||||
#include "signal.h"
|
||||
#include "sys/wait.h"
|
||||
#include "sys/signal.h"
|
||||
|
||||
#endif
|
||||
// Log4cxx
|
||||
#include "log4cxx/logger.h"
|
||||
#include "log4cxx/consoleappender.h"
|
||||
|
@ -88,6 +89,8 @@ class TemplatePlugin : public NetworkPlugin {
|
|||
Config *config;
|
||||
};
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
static void spectrum_sigchld_handler(int sig)
|
||||
{
|
||||
int status;
|
||||
|
@ -103,17 +106,18 @@ static void spectrum_sigchld_handler(int sig)
|
|||
perror(errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
std::string host;
|
||||
int port;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
if (signal(SIGCHLD, spectrum_sigchld_handler) == SIG_ERR) {
|
||||
std::cout << "SIGCHLD handler can't be set\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
boost::program_options::options_description desc("Usage: spectrum [OPTIONS] <config_file.cfg>\nAllowed options");
|
||||
desc.add_options()
|
||||
("host,h", value<std::string>(&host), "host")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# LOG4CXX_INCLUDE_DIR - the liblog4cxx include directory
|
||||
# LOG4CXX_LIBRARIES - liblog4cxx library
|
||||
|
||||
FIND_PATH(LOG4CXX_INCLUDE_DIR logger.h PATHS /include/log4cxx /usr/include/log4cxx /usr/local/include/log4cxx )
|
||||
FIND_PATH(LOG4CXX_INCLUDE_DIR log4cxx/logger.h PATHS /include /usr/include /usr/local/include )
|
||||
FIND_LIBRARY(LOG4CXX_LIBRARIES NAMES log4cxx log4cxxd PATHS /lib /usr/lib /usr/local/lib )
|
||||
|
||||
IF(LOG4CXX_INCLUDE_DIR AND LOG4CXX_LIBRARIES)
|
||||
|
|
|
@ -149,7 +149,7 @@ void Server::handleSessionFinished(boost::shared_ptr<ServerFromClientSession> se
|
|||
boost::bind(&Server::handleSessionFinished, this, session));
|
||||
}
|
||||
|
||||
void Server::addTLSEncryption(TLSServerContextFactory* tlsContextFactory, const PKCS12Certificate& cert) {
|
||||
void Server::addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert) {
|
||||
tlsFactory = tlsContextFactory;
|
||||
this->cert = cert;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "Swiften/Entity/Entity.h"
|
||||
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
|
||||
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
|
||||
#include "Swiften/TLS/PKCS12Certificate.h"
|
||||
#include <Swiften/TLS/CertificateWithKey.h>
|
||||
#include <Swiften/Parser/PlatformXMLParserFactory.h>
|
||||
|
||||
namespace Swift {
|
||||
|
@ -60,7 +60,7 @@ namespace Swift {
|
|||
boost::signal<void (const SafeByteArray&)> onDataRead;
|
||||
boost::signal<void (const SafeByteArray&)> onDataWritten;
|
||||
|
||||
void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, const PKCS12Certificate& cert);
|
||||
void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert);
|
||||
|
||||
private:
|
||||
void handleNewClientConnection(boost::shared_ptr<Connection> c);
|
||||
|
@ -84,7 +84,7 @@ namespace Swift {
|
|||
StanzaChannel *stanzaChannel_;
|
||||
IQRouter *iqRouter_;
|
||||
TLSServerContextFactory *tlsFactory;
|
||||
PKCS12Certificate cert;
|
||||
CertificateWithKey::ref cert;
|
||||
PlatformXMLParserFactory *parserFactory_;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <Swiften/Elements/StartTLSRequest.h>
|
||||
#include <Swiften/Elements/TLSProceed.h>
|
||||
#include <iostream>
|
||||
#include <Swiften/TLS/CertificateWithKey.h>
|
||||
|
||||
namespace Swift {
|
||||
|
||||
|
@ -162,7 +163,7 @@ void ServerFromClientSession::handleSessionFinished(const boost::optional<Sessio
|
|||
userRegistry_->stopLogin(JID(user_, getLocalJID().getDomain()), this);
|
||||
}
|
||||
|
||||
void ServerFromClientSession::addTLSEncryption(TLSServerContextFactory* tlsContextFactory, const PKCS12Certificate& cert) {
|
||||
void ServerFromClientSession::addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert) {
|
||||
tlsLayer = new TLSServerLayer(tlsContextFactory);
|
||||
if (!tlsLayer->setServerCertificate(cert)) {
|
||||
// std::cout << "error\n";
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <Swiften/JID/JID.h>
|
||||
#include <Swiften/Network/Connection.h>
|
||||
#include <Swiften/Base/ByteArray.h>
|
||||
#include <Swiften/TLS/CertificateWithKey.h>
|
||||
|
||||
namespace Swift {
|
||||
class ProtocolHeader;
|
||||
|
@ -49,7 +50,7 @@ namespace Swift {
|
|||
return user_;
|
||||
}
|
||||
|
||||
void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, const PKCS12Certificate& cert);
|
||||
void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert);
|
||||
|
||||
Swift::JID getBareJID() {
|
||||
return Swift::JID(user_, getLocalJID().getDomain());
|
||||
|
|
|
@ -37,7 +37,7 @@ void TLSServerLayer::handleDataRead(const SafeByteArray& data) {
|
|||
context->handleDataFromNetwork(data);
|
||||
}
|
||||
|
||||
bool TLSServerLayer::setServerCertificate(const PKCS12Certificate& certificate) {
|
||||
bool TLSServerLayer::setServerCertificate(CertificateWithKey::ref certificate) {
|
||||
return context->setServerCertificate(certificate);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "Swiften/Base/SafeByteArray.h"
|
||||
#include "Swiften/StreamStack/StreamLayer.h"
|
||||
#include "Swiften/TLS/Certificate.h"
|
||||
#include <Swiften/TLS/CertificateWithKey.h>
|
||||
#include "Swiften/TLS/CertificateVerificationError.h"
|
||||
|
||||
namespace Swift {
|
||||
|
@ -22,7 +23,7 @@ namespace Swift {
|
|||
~TLSServerLayer();
|
||||
|
||||
void connect();
|
||||
bool setServerCertificate(const PKCS12Certificate&);
|
||||
bool setServerCertificate(CertificateWithKey::ref cert);
|
||||
|
||||
Certificate::ref getPeerCertificate() const;
|
||||
boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "Swiften/Base/SafeByteArray.h"
|
||||
#include "Swiften/TLS/Certificate.h"
|
||||
#include <Swiften/TLS/CertificateWithKey.h>
|
||||
#include "Swiften/TLS/CertificateVerificationError.h"
|
||||
|
||||
namespace Swift {
|
||||
|
@ -22,7 +23,7 @@ namespace Swift {
|
|||
|
||||
virtual void connect() = 0;
|
||||
|
||||
virtual bool setServerCertificate(const PKCS12Certificate& cert) = 0;
|
||||
virtual bool setServerCertificate(CertificateWithKey::ref cert) = 0;
|
||||
|
||||
virtual void handleDataFromNetwork(const SafeByteArray&) = 0;
|
||||
virtual void handleDataFromApplication(const SafeByteArray&) = 0;
|
||||
|
|
|
@ -361,7 +361,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
#else
|
||||
if (CONFIG_STRING(&config, "database.type") == "sqlite3") {
|
||||
std::cerr << "Spectrum2 is not compiled with mysql backend.\n";
|
||||
std::cerr << "Spectrum2 is not compiled with sqlite3 backend.\n";
|
||||
return -2;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "transport/transport.h"
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include "transport/storagebackend.h"
|
||||
#include "transport/factory.h"
|
||||
|
@ -27,9 +28,15 @@
|
|||
#include "discoinforesponder.h"
|
||||
#include "discoitemsresponder.h"
|
||||
#include "storageparser.h"
|
||||
#include "Swiften/TLS/OpenSSL/OpenSSLServerContext.h"
|
||||
#ifdef _WIN32
|
||||
#include <Swiften/TLS/CAPICertificate.h>
|
||||
#include "Swiften/TLS/Schannel/SchannelServerContext.h"
|
||||
#include "Swiften/TLS/Schannel/SchannelServerContextFactory.h"
|
||||
#else
|
||||
#include "Swiften/TLS/PKCS12Certificate.h"
|
||||
#include "Swiften/TLS/OpenSSL/OpenSSLServerContext.h"
|
||||
#include "Swiften/TLS/OpenSSL/OpenSSLServerContextFactory.h"
|
||||
#endif
|
||||
#include "Swiften/Parser/PayloadParsers/AttentionParser.h"
|
||||
#include "Swiften/Serializer/PayloadSerializers/AttentionSerializer.h"
|
||||
#include "Swiften/Parser/PayloadParsers/XHTMLIMParser.h"
|
||||
|
@ -81,8 +88,14 @@ Component::Component(Swift::EventLoop *loop, Swift::NetworkFactories *factories,
|
|||
if (!CONFIG_STRING(m_config, "service.cert").empty()) {
|
||||
LOG4CXX_INFO(logger, "Using PKCS#12 certificate " << CONFIG_STRING(m_config, "service.cert"));
|
||||
LOG4CXX_INFO(logger, "SSLv23_server_method used.");
|
||||
#ifdef _WIN32
|
||||
TLSServerContextFactory *f = new SchannelServerContextFactory();
|
||||
m_server->addTLSEncryption(f, boost::make_shared<CAPICertificate>(CONFIG_STRING(m_config, "service.cert")));
|
||||
#else
|
||||
TLSServerContextFactory *f = new OpenSSLServerContextFactory();
|
||||
m_server->addTLSEncryption(f, PKCS12Certificate(CONFIG_STRING(m_config, "service.cert"), createSafeByteArray(CONFIG_STRING(m_config, "service.cert_password"))));
|
||||
m_server->addTLSEncryption(f, boost::make_shared<PKCS12Certificate>(CONFIG_STRING(m_config, "service.cert"), createSafeByteArray(CONFIG_STRING(m_config, "service.cert_password"))));
|
||||
#endif
|
||||
|
||||
}
|
||||
else {
|
||||
LOG4CXX_WARN(logger, "No PKCS#12 certificate used. TLS is disabled.");
|
||||
|
|
Loading…
Add table
Reference in a new issue