Sample code for 30+ languages & platforms
Java Requires Chilkat v11.0.0+

Example: Http.GetServerCert method

Demonstrates how to call the GetServerCert method.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.Cert;
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;

public class ChilkatExample {

    public static void main(String[] args) {
        Http http = new Http();
        Cert cert = new Cert();

        try {
            http.getServerCert("chilkatsoft.com", 443, cert);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println(cert.getSubjectDN());
        System.out.println(cert.getValidToStr());

        // Output:

        // CN=*.chilkatsoft.com
        // Wed, 10 Jun 2026 23:59:59 GMT
    }
}