Tuesday, July 19, 2005, 11:26:21 AM, you wrote:

JS> Hi, folks,

JS> https://www.denix.osd.mil/  has a suspicious certificate, but I want
JS> it to get past my link checker program all the same.  I suppose I
JS> could just allow an SSLHandshakeException "pass" the link checker
JS> test, or I could have it ignore this URL altogether, but is there a
JS> way that I can accept the certificate in this case, preferably from
JS> the command line?

JS> Example code and stack trace follow.

JS> TIA,
JS> Jim

JS> import java.net.URI;
JS> import java.net.URL;
JS> import java.net.URLConnection;

JS> public class TestHttps {
JS>     public static void main(String[] args) throws Exception {
JS>             URI uri=new URI("https://www.denix.osd.mil/";);
JS>             URL url=uri.toURL();
JS>             URLConnection conn=url.openConnection();
JS>             conn.connect(); // exception here
JS>     }
JS> }


Hello Jim,
May not fit your needs but I've done this will Apache's HTTPClient and
would guess it's doable using straight java.net. I highly recommend
HTTPClient over java.net.

In HTTPClient I did:
Protocol.registerProtocol("https", new Protocol("https", 
(ProtocolSocketFactory)new EasySSLProtocolSocketFactory(), 443));
Not sure if java.net has something similar or not.

EasySSLProtocolSocketFactory is based off an example of accepting
self-signed certificates I found in SVN on httpclient (which is down
at the moment). Let me know if you want it and I can post my version.

I made a couple of changes so it would work in IBM and Sun VMs and
moved it to the javax impl instead of the internal Sun impl.

Opera tells me that
- The certificate for "www.denix.osd.mil" is signed by the unknown Certificate 
Authority "DOD CLASS 3 CA-4". It is not possible to verify that this is a valid 
certificate

More info:
http://jakarta.apache.org/commons/httpclient/sslguide.html

FWIW I tried hitting that site with my HTTPClient code and it works
fine.

Chris
-- 
Chris Grindstaff | http://gstaff.org


_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to