diff options
-rw-r--r-- | BuildTools/SCons/SConstruct | 1 | ||||
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | Swift/SConscript | 2 | ||||
-rw-r--r-- | Swiften/Client/ClientSession.cpp | 12 | ||||
-rw-r--r-- | Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp | 6 | ||||
-rw-r--r-- | Swiften/TLS/PlatformTLSFactories.cpp | 8 | ||||
-rw-r--r-- | Swiften/TLS/SConscript | 3 |
7 files changed, 24 insertions, 15 deletions
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct index 6f4354f..b3d3c8f 100644 --- a/BuildTools/SCons/SConstruct +++ b/BuildTools/SCons/SConstruct @@ -406,18 +406,19 @@ if use_openssl and openssl_conf.CheckCHeader("openssl/ssl.h") : if env["PLATFORM"] == "darwin" : if platform.mac_ver()[0].startswith("10.5") : env["OPENSSL_FLAGS"]["FRAMEWORKS"] = ["Security"] elif env["target"] in ("iphone-device", "iphone-simulator", "xcode") : env["OPENSSL_BUNDLED"] = True env["HAVE_OPENSSL"] = True else : env["OPENSSL_FLAGS"] = "" if env["PLATFORM"] == "win32" : + env["HAVE_SCHANNEL"] = True # If we're compiling for Windows and OpenSSL isn't being used, use Schannel env.Append(LIBS = ["secur32"]) openssl_conf.Finish() # Bonjour if env["PLATFORM"] == "darwin" : env["HAVE_BONJOUR"] = 1 elif env.get("bonjour", False) : @@ -1,7 +0,0 @@ - -We have moved the Swift Git repositories to http://swift.im/git -This site also hosts the contributors' repositories. - -This Gitorious mirror will no longer be used for Swift development. - - -- The Swift team diff --git a/Swift/SConscript b/Swift/SConscript index a1ee3ae..b66058b 100644 --- a/Swift/SConscript +++ b/Swift/SConscript @@ -1,16 +1,16 @@ import datetime Import("env") SConscript("Controllers/SConscript") if env["SCONS_STAGE"] == "build" : - if not GetOption("help") and not env.get("HAVE_OPENSSL", 0) : + if not GetOption("help") and not env.get("HAVE_OPENSSL", 0) and not env.get("HAVE_SCHANNEL", 0) : print "Error: Swift requires OpenSSL support, and OpenSSL was not found." if "Swift" in env["PROJECTS"] : env["PROJECTS"].remove("Swift") elif not GetOption("help") and not env.get("HAVE_QT", 0) : print "Error: Swift requires Qt. Not building Swift." env["PROJECTS"].remove("Swift") elif env["target"] == "native": SConscript("QtUI/SConscript") diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index fd001a1..55e0bc2 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -195,22 +195,28 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) { finishSession(Error::TLSClientCertificateError); } } else if (streamFeatures->hasAuthenticationMechanism("EXTERNAL")) { state = Authenticating; stream->writeElement(boost::make_shared<AuthRequest>("EXTERNAL", createSafeByteArray(""))); } else if (streamFeatures->hasAuthenticationMechanism("SCRAM-SHA-1") || streamFeatures->hasAuthenticationMechanism("SCRAM-SHA-1-PLUS")) { std::ostringstream s; + ByteArray finishMessage; + bool plus = stream->isTLSEncrypted() && streamFeatures->hasAuthenticationMechanism("SCRAM-SHA-1-PLUS"); + if (plus) { + finishMessage = stream->getTLSFinishMessage(); + plus &= !finishMessage.empty(); + } s << boost::uuids::random_generator()(); - SCRAMSHA1ClientAuthenticator* scramAuthenticator = new SCRAMSHA1ClientAuthenticator(s.str(), streamFeatures->hasAuthenticationMechanism("SCRAM-SHA-1-PLUS")); - if (stream->isTLSEncrypted()) { - scramAuthenticator->setTLSChannelBindingData(stream->getTLSFinishMessage()); + SCRAMSHA1ClientAuthenticator* scramAuthenticator = new SCRAMSHA1ClientAuthenticator(s.str(), plus); + if (plus) { + scramAuthenticator->setTLSChannelBindingData(finishMessage); } authenticator = scramAuthenticator; state = WaitingForCredentials; onNeedCredentials(); } else if ((stream->isTLSEncrypted() || allowPLAINOverNonTLS) && streamFeatures->hasAuthenticationMechanism("PLAIN")) { authenticator = new PLAINClientAuthenticator(); state = WaitingForCredentials; onNeedCredentials(); diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp index ac36f4f..76b8bb9 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp @@ -30,25 +30,31 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) { cert = boost::shared_ptr<X509>(d2i_X509(NULL, &p, der.size()), X509_free); if (!cert) { SWIFT_LOG(warning) << "Error creating certificate from DER data" << std::endl; } parse(); } ByteArray OpenSSLCertificate::toDER() const { ByteArray result; + if (!cert) { + return result; + } result.resize(i2d_X509(cert.get(), NULL)); unsigned char* p = vecptr(result); i2d_X509(cert.get(), &p); return result; } void OpenSSLCertificate::parse() { + if (!cert) { + return; + } // Subject name X509_NAME* subjectName = X509_get_subject_name(cert.get()); if (subjectName) { // Subject name ByteArray subjectNameData; subjectNameData.resize(256); X509_NAME_oneline(X509_get_subject_name(cert.get()), reinterpret_cast<char*>(vecptr(subjectNameData)), subjectNameData.size()); this->subjectName = byteArrayToString(subjectNameData); diff --git a/Swiften/TLS/PlatformTLSFactories.cpp b/Swiften/TLS/PlatformTLSFactories.cpp index 5f57793..64a5ab3 100644 --- a/Swiften/TLS/PlatformTLSFactories.cpp +++ b/Swiften/TLS/PlatformTLSFactories.cpp @@ -7,30 +7,32 @@ #include <Swiften/Base/Platform.h> #include <Swiften/TLS/PlatformTLSFactories.h> #include <cstring> #include <cassert> #ifdef HAVE_OPENSSL #include "Swiften/TLS/OpenSSL/OpenSSLContextFactory.h" #include "Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h" -#elif defined SWIFTEN_PLATFORM_WINDOWS +#endif +#ifdef HAVE_SCHANNEL #include "Swiften/TLS/Schannel/SchannelContextFactory.h" -#include "Swiften/TLS/Schannel/SchannelCertificateFactory.h" + #include "Swiften/TLS/Schannel/SchannelCertificateFactory.h" #endif namespace Swift { PlatformTLSFactories::PlatformTLSFactories() : contextFactory(NULL), certificateFactory(NULL) { #ifdef HAVE_OPENSSL contextFactory = new OpenSSLContextFactory(); certificateFactory = new OpenSSLCertificateFactory(); -#elif defined SWIFTEN_PLATFORM_WINDOWS +#endif +#ifdef HAVE_SCHANNEL contextFactory = new SchannelContextFactory(); certificateFactory = new SchannelCertificateFactory(); #endif } PlatformTLSFactories::~PlatformTLSFactories() { delete contextFactory; delete certificateFactory; } diff --git a/Swiften/TLS/SConscript b/Swiften/TLS/SConscript index 225aa0a..a71a446 100644 --- a/Swiften/TLS/SConscript +++ b/Swiften/TLS/SConscript @@ -12,21 +12,22 @@ objects = swiften_env.SwiftenObject([ myenv = swiften_env.Clone() if myenv.get("HAVE_OPENSSL", 0) : myenv.MergeFlags(myenv["OPENSSL_FLAGS"]) objects += myenv.SwiftenObject([ "OpenSSL/OpenSSLContext.cpp", "OpenSSL/OpenSSLCertificate.cpp", "OpenSSL/OpenSSLContextFactory.cpp", ]) myenv.Append(CPPDEFINES = "HAVE_OPENSSL") -elif myenv["PLATFORM"] == "win32" : +elif myenv.get("HAVE_SCHANNEL", 0) : objects += myenv.StaticObject([ "Schannel/SchannelContext.cpp", "Schannel/SchannelCertificate.cpp", "Schannel/SchannelContextFactory.cpp", ]) + myenv.Append(CPPDEFINES = "HAVE_SCHANNEL") objects += myenv.SwiftenObject(["PlatformTLSFactories.cpp"]) swiften_env.Append(SWIFTEN_OBJECTS = [objects]) |