Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SSL implementation for HTTPClient  RSS feed

 
batuk chatuk
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m trying to implement SSL for HTTPClient(a desktop app that talks with the server. Server is configured to handle https request)

I found 3 ways of doing this but i m not getting how to implement them. Like how can we get a security prompt on a desktop app ???(no browser involved..)

heres the link .. http://commons.apache.org/httpclient/sslguide.html

The call i make from HTTPClient is like this...

PostMethod postMethod = getPostMethodObject("http:/abc/mycontroller");

postMethod.addParameter("userId", userNameText);
postMethod.addParameter("orgId", orgIdText);
postMethod.addParameter("password", passwordText);
postMethod.addParameter("isContinue", isContinue);
HttpClient httpClient = new HttpClient();
int status = httpClient.executeMethod(postMethod);

how can i mae all such requests to https???

Please help.
Thanks
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just change the URL to https. JSSE is installed by default. With HttpClient, you don't need to do anything unless you want to use different security provider.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you are asking. You make requests via HTTPS by using an HTTPS URL instead of an HTTP one.

The dialog you get in the browser usually asks you if want to accept a certificate by an unknown authority, or an expired certificate. You can change how those cases are handled by using custom socket factories, as is described in the paragraph titled "Examples of SSL customization in HttpClient".
 
batuk chatuk
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.. I can use JSSE directly. but then i decided to go with the StrictSSLProtocolSocketFactory implementation from Apache. I could run the app with this. I dowwnloaded the source and put the contrib package in my classpath and got it working.

But the problem is that in commons-httpclient.jar they dont provide this class (I checked all the versions) and I want to have the jar from the trusted source. So there should be a different jar for the contrib package of this class.

does anyone know from where can I find that jar?? I guess Apache should be providing that.

thnks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!