How can I set up an SSLContext with TLS using Spongy Castle? I'm searching online but cannot find any good examples.
Asked
Active
Viewed 1,125 times
1
-
Bouncy Castle and by extension Spongy Castle doesn't come with a JSSE provider, so this doesn't really make sense. What are you trying to do? – Nikolay Elenkov Oct 16 '12 at 09:03
-
I'm trying to set up a TrustManager for passing into sslContext.init(). I'm calling TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm(), "SC"), but Spongy Castle doesn't have any services of type "TrustManager". – Phillip Oct 16 '12 at 15:06
-
So why are you using SC for this? Just use the platform one (no provider parameter). – Nikolay Elenkov Oct 16 '12 at 15:14
-
I may plan on using parts of SC that are not included in Android's implementation of BC. – Phillip Oct 16 '12 at 15:16
-
OK, so use them. But you cannot use something that is not there, i.e., JSSE, TrustManager, etc. – Nikolay Elenkov Oct 16 '12 at 15:23
1 Answers
3
This cannot really be done, since Bouncy Castle and by extension Spongy Castle doesn't come with a JSSE provider. Use the platform default versions (don't specify a provider). When you need a specific algorithm that is not included in the system JCE providers, specify the SC provider explicitly.

Nikolay Elenkov
- 52,576
- 10
- 84
- 84
-
I see; so if I understand correctly, neither Spongy Castle nor Bouncy Castle can be used as trust store providers when setting up an SSL/TLS connection? – Phillip Oct 16 '12 at 16:02
-
Right. BTW, Spongy Castle is exactly the same as Bouncy Castle only with a different name so as not to clash with the one bundled in Android. Bouncy Castle does not offer a JSSE implementation, so you cannot use it for SSL. Details here: http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html – Nikolay Elenkov Oct 16 '12 at 16:12