summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Clayton <alex.clayton@isode.com>2016-03-14 11:44:35 (GMT)
committerAlex Clayton <alex.clayton@isode.com>2016-03-15 14:10:50 (GMT)
commit3dcfa7102ac07188ac0c1c8b252d45735abd31ea (patch)
tree1736bd29e6a12cffcbbd64741a26b72426b36dfa /src/com/isode
parent63a5013833f0be3aac1d15df1ac200d48d747136 (diff)
downloadstroke-3dcfa7102ac07188ac0c1c8b252d45735abd31ea.zip
stroke-3dcfa7102ac07188ac0c1c8b252d45735abd31ea.tar.bz2
Fix handling when client certificate is missing
As per patch 'Fix swiften handling when client certificate is missing' (8405fa16b738b6ef6a5920cd9d0f5735f8b62369). Change-Id: Iec5036213d8432a3af78647470381485bfcc01e3 Test-information: Code inspection. Unit tests still pass.
Diffstat (limited to 'src/com/isode')
-rw-r--r--src/com/isode/stroke/client/CoreClient.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/com/isode/stroke/client/CoreClient.java b/src/com/isode/stroke/client/CoreClient.java
index 010a535..6cb0d5d 100644
--- a/src/com/isode/stroke/client/CoreClient.java
+++ b/src/com/isode/stroke/client/CoreClient.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2015, Isode Limited, London, England.
+ * Copyright (c) 2010-2016, Isode Limited, London, England.
* All rights reserved.
*/
package com.isode.stroke.client;
@@ -347,11 +347,20 @@ public class CoreClient {
}
else {
assert (connection_ == null);
- connection_ = connection;
-
assert (sessionStream_ == null);
- sessionStream_ = new BasicSessionStream(StreamType.ClientStreamType, connection_, payloadParserFactories_, payloadSerializers_, networkFactories.getTLSContextFactory(), networkFactories.getTimerFactory(), options.tlsOptions);
- if (certificate_ != null && !certificate_.isNull()) {
+
+ if (certificate_ != null && certificate_.isNull()) {
+ // Certificate can not be read so do not initialise session
+ onDisconnected.emit(new ClientError(ClientError.Type.ClientCertificateLoadError));
+ return;
+ }
+
+ connection_ = connection;
+
+ sessionStream_ =
+ new BasicSessionStream(StreamType.ClientStreamType, connection_, payloadParserFactories_, payloadSerializers_,
+ networkFactories.getTLSContextFactory(), networkFactories.getTimerFactory(), options.tlsOptions);
+ if (certificate_ != null) {
sessionStream_.setTLSCertificate(certificate_);
}
sessionStreamDataReadConnection_ = sessionStream_.onDataRead.connect(new Slot1<SafeByteArray>() {