
Signature
Groetjes, Peter
.\\ PGP/GPG key: http://www.catslair.org/pubkey.asc
> >> HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
>
[quoted text clipped - 4 lines]
> javax.net.ssl.HttpsURLConnection is an abstract class with a protected
> constructor? You don't simply "instantiate" it.
I believe this includes new instances of child classes of
HttpsURLConnection, which can be instantiated.
> In the book example they define a reference to it through use of the
> java.net.URL.openConnection() method and casting its result to a
> HttpsURLConnection object. This automaticly implies that all further
> operations will be using the /current/ object and not any optional new
> instances.
I don't see openConnection() called in the book example. Therefore I
think the example shows that by calling
HttpsURLConnection.setDefaultSSLSocketFactory(...) all URLs created
later can "automagically" use the new TrustManager. Maybe you can use
openConnection() and call setSSLSocketFactory(...) on the object you
get. That's another topic. It doesn't mean this example is incorrect.
> Therefor you need setSSLSocketFactory() because the settings need to
> apply to new sockets created by the current instance.
[quoted text clipped - 3 lines]
>
> .\\ PGP/GPG key:http://www.catslair.org/pubkey.asc
Lion-O - 26 Nov 2006 02:15 GMT
>> Notice how javax.net.ssl.HttpsURLConnection is an abstract class with
>> a protected constructor? You don't simply "instantiate" it.
> I believe this includes new instances of child classes of
> HttpsURLConnection, which can be instantiated.
You are right, but thats not what the book is using hence my comment.
> I don't see openConnection() called in the book example. Therefore I
> think the example shows that by calling
> HttpsURLConnection.setDefaultSSLSocketFactory(...)
Thats incorrect. This method does not open a connection.
And once again, the last time I will repeat this, opening a connection
applies to the /current/ instance.

Signature
Groetjes, Peter
.\\ PGP/GPG key: http://www.catslair.org/pubkey.asc
sgoo - 26 Nov 2006 02:38 GMT
What I mean is, there are 2 ways:
1. Call HttpsURLConnection.setDefaultSSLSocketFactory(...), and all
HTTPS URL created later can go on
2. Call
((HttpsURLConnection)(myURL.getConnection())).setSSLSocketFactory(...)
and /this/ URL can go on
Either works. You just cannot say the first is wrong if you prefer the
second one.