java api with self-signed certificate

LabKey Support Forum (Inactive)
java api with self-signed certificate jdutra  2012-05-02 09:00
Status: Closed
 
I am trying to test some java code that uses the labkey api on our development server, which has a self-signed certificate. I get a slew of certification errors from httpclient. I am using the following:

Connection cn = new org.labkey.remoteapi.Connection("https://my-development-server/labkey");
cn.setEmail(userName);
cn.setPassword(passWord);
cn.setAcceptSelfSignedCerts(true);

Adding the last line did not change anything at all. Does the setAcceptSelfSignedCerts method work? Or am I doing something wrong? If someone could suggest a way to work around this, that would be terrific.

- Jen
 
 
Matthew Bellew responded:  2012-05-02 10:19
This is not a definitive answer, but I got very frustrated trying to get Java to accept non-standard certificates. Since this is a development server, perhaps you could turn off the "Require SSL connections" in the site settings, and connect via "http:".

There is also some pointers to discussion on this topic here

https://www.labkey.org/announcements/home/Developer/Forum/thread.view?entityId=9021b8ac-857c-102c-86c6-d104f9cdea0a

Matt
 
dennisw responded:  2012-05-02 12:20
 
jeckels responded:  2012-05-02 12:32
Hi Jen,

Could you post the exceptions you're getting?

I'm considering making a change to the way that setAcceptSelfSignedCerts() works so that it follows the pattern that I suggested in my other post. But first, I'd like to see what's happening that doesn't work with the existing implementation.

Thanks,
Josh
 
jdutra responded:  2012-05-03 13:51
Josh,

I'm attaching an error log - I'm not sure if it will be any help or not. I tried Matt's suggestion, and ended up adding the certificate to Java's keystore as recommended in the workaround in the other thread. That worked - I no longer get the error.