probing SSL websites

Discussion in 'Java' started by Roedy Green, Jan 17, 2013.

  1. Roedy Green

    Roedy Green Guest

    Is there an easy way to find out the certificate details of the SSL
    cert a site is using, in particular what root certs you need for it to
    be recognised?

    When do a probe an SSL website in Java, and you don't have the
    necessary root, what is supposed to happen? It seems to act as if the
    site just did not respond.
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    The first 90% of the code accounts for the first 90% of the development time.
    The remaining 10% of the code accounts for the other 90% of the development
    time.
    ~ Tom Cargill Ninety-ninety Law
     
    Roedy Green, Jan 17, 2013
    #1
    1. Advertising

  2. Roedy Green

    Arne Vajhøj Guest

    On 1/17/2013 8:09 AM, Roedy Green wrote:
    > Is there an easy way to find out the certificate details of the SSL
    > cert a site is using, in particular what root certs you need for it to
    > be recognised?


    The following may reveal somnething:

    import java.io.IOException;
    import java.net.URL;
    import java.security.KeyManagementException;
    import java.security.NoSuchAlgorithmException;
    import java.security.cert.Certificate;
    import java.security.cert.X509Certificate;

    import javax.net.ssl.HttpsURLConnection;


    public class CertSniff {
    public static void dump(String urlstr) throws NoSuchAlgorithmException,
    KeyManagementException, IOException {
    System.out.println("URL=" + urlstr);
    URL url = new URL(urlstr);
    HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
    if (con.getResponseCode() == HttpsURLConnection.HTTP_OK) {
    for(Certificate cert : con.getServerCertificates()) {
    if(cert instanceof X509Certificate) {
    X509Certificate cert509 = (X509Certificate)cert;
    System.out.println("Subject = " + cert509.getSubjectDN());
    System.out.println("Issuer = " + cert509.getIssuerDN());
    } else {
    System.out.println("Unknown certificate");
    }
    }
    } else {
    System.out.println("Connection problem");
    }
    con.disconnect();

    }
    public static void main(String[] args) throws Exception {
    dump("https://www.google.com/");
    dump("https://www.facebook.com/");
    dump("https://www.microsoft.com/");
    }
    }

    Arne
     
    Arne Vajhøj, Jan 18, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,984
    Jim Lewis
    Dec 20, 2004
  2. Stan
    Replies:
    1
    Views:
    609
    Jacob Yang [MSFT]
    Oct 20, 2003
  3. Pavils Jurjans

    Assembly probing does not work

    Pavils Jurjans, May 11, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,391
    Pavils Jurjans
    May 12, 2004
  4. Jiho Han

    <probing> element in Web.config

    Jiho Han, Jun 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    5,105
    Jiho Han
    Jun 8, 2004
  5. =?Utf-8?B?VHlydmVu?=

    Resource Probing Issue - Troubleshooting help?

    =?Utf-8?B?VHlydmVu?=, Mar 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    543
    =?Utf-8?B?VHlydmVu?=
    Mar 27, 2005
Loading...

Share This Page