简体   繁体   中英

How can I inspect a HTTPS certificate before making a connection

I'm trying, in java, to connect to a HTTPS endpoint. The server's certificate is signed by an internal CA. (not included in the truststore). Because of that, connection fails as expected

How can I inspect a certificate from a https server before the connection is made (in java). I need to view it to know what CA certificate I need to import.

I can do this using openssl like so openssl s_client -connect www.paypal.com:443

But I would like to do this from Java

Thanks!

You do a connection with disabled chain verfication. You could find an example there: http://www.nakov.com/blog/2009/07/16/disable-certificate-validation-in-java-ssl-connections/

After having the insecure connection you could inspect the certificate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM