summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Hudson <nick.hudson@isode.com>2012-03-19 17:43:01 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-03-29 15:59:06 (GMT)
commit1cf764950ad4675b9192a1d76e422415e377216b (patch)
treea8761107481e7573b74c30622be650ea36bdc191
parentc194f7d215935cded5b2eab4daeed725a5a4069c (diff)
downloadstroke-1cf764950ad4675b9192a1d76e422415e377216b.zip
stroke-1cf764950ad4675b9192a1d76e422415e377216b.tar.bz2
Make CoreClient.getSessionCertificate more robust
The javadoc for the method was not in line with its behaviour, so you could get a NullPointerException if you asked for a session certificate when the session wasn't TLS. This patch makes the code do what the javadoc says (and what clients most likely want) Test-information: Returns null rather than crashing when I ask for a certificate on a non-TLS stream.
-rw-r--r--src/com/isode/stroke/client/CoreClient.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/com/isode/stroke/client/CoreClient.java b/src/com/isode/stroke/client/CoreClient.java
index 453307e..eca9fda 100644
--- a/src/com/isode/stroke/client/CoreClient.java
+++ b/src/com/isode/stroke/client/CoreClient.java
@@ -420,7 +420,7 @@ public class CoreClient {
* @return the peer certificate, if one is available, otherwise null.
*/
public Certificate getSessionCertificate() {
- return (sessionStream_ == null ? null : sessionStream_.getPeerCertificate());
+ return (isSessionTLSEncrypted() ? sessionStream_.getPeerCertificate() : null);
}