Hi,

On 07/06/2010 22:45, p Nut wrote:
> I am trying to write a java client which calls the web service. all the 
> following circumstances work.
> -access service using browser using http and also https. Using https, I can 
> access my service using a browser. I will have to accept the exception in 
> firefox tough.
>
> -java client using http.
> But i am not able to have my java client call the service using https
>
> So i followed the instructions in "configuring https " 
> http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/46-restlet/213-restlet.pdf
> and also followed the thread HTTP over SSL. 
> http://restlet.tigris.org/ds/viewMessage.do?dsMessageId=2610413&dsForumId=4447
>
> I have imported the cert into my client jvm cacerts using keytool as 
> mentioned in the instructions  in the above link.

You don't really need to set the system property to point to this 
cacerts file, since that would be the default value anyway. In addition, 
I wouldn't recommend to change the JRE's cacerts by hand (at least when 
experimenting), I tend to prefer to use another file. In this case you'd 
have to configure it to be a trust store, which I would do via the 
context's trustStore parameter rather than the global system property.


> Here is the code which I am using on my client side.
> System.setProperty("javax.net.ssl.trustStore", 
> "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/lib/security/cacerts");
> String uri = "https://xyz:8443/webservice/get";;
> ClientResource clientResource = new ClientResource(new Context(), new 
> Reference(uri));
> clientResource.setProtocol(Protocol.HTTPS);
> clientResource.get();
> if (clientResource.getStatus().isSuccess()
>                  &&  clientResource.getResponseEntity().isAvailable()) {
>              Representation rep = clientResource.getResponseEntity();
> }
>
> I am getting the following error
> at this step: clientResource.get();
> Version Not Supported (505) - HTTP Version Not Supported
>          at org.restlet.resource.ClientResource.get(ClientResource.java:452)

Can you try it outside Tomcat as a standalone application? I've just 
tried the following and it worked fine:

String uri = "https://www.google.com/";;
ClientResource clientResource = new ClientResource(new Context(), new 
Reference(uri));
// clientResource.setProtocol(Protocol.HTTPS);
clientResource.get();
if (clientResource.getStatus().isSuccess()
         && clientResource.getResponseEntity().isAvailable()) {
     Representation rep = clientResource.getResponseEntity();
     rep.write(System.out);
}

Would this work for you on your service?


You mentioned an error message with Firefox, is it just a warning about 
the certificate not being trusted, or something else (does the server 
cert have the appropriate host name too, for example)?


Best wishes,

Bruno.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2618385

Reply via email to