Thanks Oleg, I just figured it out myself (it helps to read your tutorial :)
For anyone out there interested here's the code that worked for me
SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
sslSocketFactory.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
registry.register(new Scheme("https", sslSocketFactory, 443));
olegk wrote:
>
> droidin.net wrote:
>> Hi Oleg,
>>
>> It's ether nibble or I'm slow - I only got word "This" from your reply.
>> If
>> I'm doing these 2 lines wrong how should I do it?
>>
>> Regards,
>>
>> Bo
>>
>
> Sorry about being so terse. You certainly do not want PlainSocketFactory
> to be registered as a socket factory for the HTTPS scheme. Use
> SSLSocketFactory instead.
>
> Hope this helps
>
> Oleg
>
>
>>
>> olegk wrote:
>>> On Wed, Aug 26, 2009 at 01:19:17PM -0700, droidin.net wrote:
>>>> I define HttpClient in 2 different ways:
>>>> 1. Plain vanilla: client = new DefaultHttpClient();
>>>> 2. Thread safe:
>>>> private DefaultHttpClient getThreadSafeHttpClient() {
>>>> HttpParams params = new BasicHttpParams();
>>>> params.setParameter("http.useragent", USER_AGENT);
>>>> HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
>>>> HttpProtocolParams.setContentCharset(params, "UTF-8");
>>>> final SchemeRegistry registry = new SchemeRegistry();
>>>> registry.register(new Scheme("http",
>>>> PlainSocketFactory.getSocketFactory(), 80));
>>>> registry.register(new Scheme("https",
>>>> PlainSocketFactory.getSocketFactory(), 443));
>>> This.
>>>
>>> Oleg
>>>
>>>
>>>
>>>> final ThreadSafeClientConnManager manager = new
>>>> ThreadSafeClientConnManager(params, registry);
>>>> return new DefaultHttpClient(manager, params);
>>>> }
>>>>
>>>> Then I run same JUnit test for both client types (simple GET request).
>>>> #1
>>>> always runs fine, #2 always fails with "java.net.SocketException:
>>>> Connection
>>>> reset". Debug/stacktrace output attached (fictitious site)
>>>>
>>>> I never get a chance to do anything with entity object since error is
>>>> thrown
>>>> at client#execute call
>>>>
>>>> http://www.nabble.com/file/p25157321/error.log error.log
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/ThreadSafeClientConnManager-and-java.net.SocketException%3A-Connection-reset-tp25157321p25157321.html
>>>> Sent from the HttpClient-User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://www.nabble.com/ThreadSafeClientConnManager-and-java.net.SocketException%3A-Connection-reset-tp25157321p25177945.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]