summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-11-03 18:52:03 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-11-03 20:54:36 (GMT)
commit7a26e76bd05283fcc329469d25a2640107966603 (patch)
tree6aaab1a11cc344d5dd59302450ba70c350963847
parent7b0795215f601a9561dbedbed3af32dbe9aba032 (diff)
downloadswift-contrib-7a26e76bd05283fcc329469d25a2640107966603.zip
swift-contrib-7a26e76bd05283fcc329469d25a2640107966603.tar.bz2
Quick brush up after previous patch.
Includes: Initial cleanup of SChannel code; compiling on non-Windows Be willing to compile Swift with SChannel Undo some (presumably accidental) OpenSSL changes Where TLS doesn't support finish messages (SChannel), don't try -PLUS
-rw-r--r--BuildTools/SCons/SConstruct1
-rw-r--r--README7
-rw-r--r--Swift/SConscript2
-rw-r--r--Swiften/Client/ClientSession.cpp12
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp6
-rw-r--r--Swiften/TLS/PlatformTLSFactories.cpp8
-rw-r--r--Swiften/TLS/SConscript3
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
@@ -412,6 +412,7 @@ elif env["target"] in ("iphone-device", "iphone-simulator", "xcode") :
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"])
diff --git a/README b/README
deleted file mode 100644
index 436472b..0000000
--- a/README
+++ /dev/null
@@ -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
@@ -5,7 +5,7 @@ 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")
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
@@ -201,10 +201,16 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
}
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;
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
@@ -36,6 +36,9 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) {
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);
@@ -43,6 +46,9 @@ ByteArray OpenSSLCertificate::toDER() const {
}
void OpenSSLCertificate::parse() {
+ if (!cert) {
+ return;
+ }
// Subject name
X509_NAME* subjectName = X509_get_subject_name(cert.get());
if (subjectName) {
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
@@ -13,9 +13,10 @@
#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 {
@@ -24,7 +25,8 @@ PlatformTLSFactories::PlatformTLSFactories() : contextFactory(NULL), certificate
#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
diff --git a/Swiften/TLS/SConscript b/Swiften/TLS/SConscript
index 225aa0a..a71a446 100644
--- a/Swiften/TLS/SConscript
+++ b/Swiften/TLS/SConscript
@@ -18,12 +18,13 @@ if myenv.get("HAVE_OPENSSL", 0) :
"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"])