Java
Java
Example: Http.GetServerCert method
Demonstrates how to call the GetServerCert method.Chilkat Java Downloads
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
boolean success = false;
CkHttp http = new CkHttp();
CkCert cert = new CkCert();
success = http.GetServerCert("chilkatsoft.com",443,cert);
if (success == false) {
System.out.println(http.lastErrorText());
return;
}
System.out.println(cert.subjectDN());
System.out.println(cert.validToStr());
// Output:
// CN=*.chilkatsoft.com
// Wed, 10 Jun 2026 23:59:59 GMT
}
}