From 2a1c515b337bde1ad4a95888902cd7c9a8ef1aab Mon Sep 17 00:00:00 2001 From: Nick Hudson Date: Tue, 3 Dec 2013 17:04:06 +0000 Subject: Fix possible ClassCastException when restricting ciphers Old code was casting Object[] to String[], which may be safe, but is dependant on the Set's internal implementation of toArray, and may lead to ClassCastExceptions. We now preallocate a String[] to avoid the cast and force type safety for any implementation. Test-information: Was crashing when enabling restricted ciphers on Android. Now works OK. Change-Id: I759a369449296f1819e91a25aa123b083ec280c9 Signed-off-by: Nick Hudson diff --git a/src/com/isode/stroke/tls/java/JSSEContext.java b/src/com/isode/stroke/tls/java/JSSEContext.java index 77b9447..2928498 100644 --- a/src/com/isode/stroke/tls/java/JSSEContext.java +++ b/src/com/isode/stroke/tls/java/JSSEContext.java @@ -163,7 +163,7 @@ public class JSSEContext extends TLSContext { } String[] suitesToEnable = new String[]{}; if (!matchedSuites.isEmpty()) { - suitesToEnable = (String[])matchedSuites.toArray(); + suitesToEnable = matchedSuites.toArray(new String[matchedSuites.size()]); } sslEngine.setEnabledCipherSuites(suitesToEnable); -- cgit v0.10.2-6-g49f6