summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-03-23 11:54:03 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-03-23 11:54:03 (GMT)
commit846c4b9d2e7ec3214a3b13bdbbce77f70fede515 (patch)
tree579bf6be3e266c8e28a7469e7547ac88fa9af3fc /Swiften/TLS/OpenSSL/OpenSSLContext.cpp
parent8ccdfd958ba1e7afbeb8c5893c12f09046cb8892 (diff)
downloadswift-contrib-846c4b9d2e7ec3214a3b13bdbbce77f70fede515.zip
swift-contrib-846c4b9d2e7ec3214a3b13bdbbce77f70fede515.tar.bz2
Allow TLS errors to bubble further up the stackks/tlserrors
Diffstat (limited to 'Swiften/TLS/OpenSSL/OpenSSLContext.cpp')
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContext.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp
index 54addef..8c03052 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp
+++ b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp
@@ -126,19 +126,19 @@ void OpenSSLContext::doConnect() {
//std::cout << "Compression: " << SSL_COMP_get_name(comp) << std::endl;
onConnected();
break;
}
case SSL_ERROR_WANT_READ:
sendPendingDataToNetwork();
break;
default:
state_ = Error;
- onError();
+ onError(boost::make_shared<TLSError>());
}
}
void OpenSSLContext::sendPendingDataToNetwork() {
int size = BIO_pending(writeBIO_);
if (size > 0) {
SafeByteArray data;
data.resize(size);
BIO_read(writeBIO_, vecptr(data), size);
@@ -160,35 +160,35 @@ void OpenSSLContext::handleDataFromNetwork(const SafeByteArray& data) {
}
}
void OpenSSLContext::handleDataFromApplication(const SafeByteArray& data) {
if (SSL_write(handle_, vecptr(data), data.size()) >= 0) {
sendPendingDataToNetwork();
}
else {
state_ = Error;
- onError();
+ onError(boost::make_shared<TLSError>());
}
}
void OpenSSLContext::sendPendingDataToApplication() {
SafeByteArray data;
data.resize(SSL_READ_BUFFERSIZE);
int ret = SSL_read(handle_, vecptr(data), data.size());
while (ret > 0) {
data.resize(ret);
onDataForApplication(data);
data.resize(SSL_READ_BUFFERSIZE);
ret = SSL_read(handle_, vecptr(data), data.size());
}
if (ret < 0 && SSL_get_error(handle_, ret) != SSL_ERROR_WANT_READ) {
state_ = Error;
- onError();
+ onError(boost::make_shared<TLSError>());
}
}
bool OpenSSLContext::setClientCertificate(CertificateWithKey::ref certificate) {
boost::shared_ptr<PKCS12Certificate> pkcs12Certificate = boost::dynamic_pointer_cast<PKCS12Certificate>(certificate);
if (!pkcs12Certificate || pkcs12Certificate->isNull()) {
return false;
}