From 1cf764950ad4675b9192a1d76e422415e377216b Mon Sep 17 00:00:00 2001 From: Nick Hudson Date: Mon, 19 Mar 2012 17:43:01 +0000 Subject: 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. 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); } -- cgit v0.10.2-6-g49f6