Sample code for 30+ languages & platforms
Java

Transition from Http.GetServerSslCert to Http.GetServerCert

See more HTTP Examples

Provides instructions for replacing deprecated GetServerSslCert method calls with GetServerCert.

Chilkat Java Downloads

Java
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();
    String domain = "chilkatsoft.com";
    int port = 443;

    //  ------------------------------------------------------------------------
    //  The GetServerSslCert method is deprecated:

    CkCert cert1 = http.GetServerSslCert(domain,port);
    if (http.get_LastMethodSuccess() == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println(cert1.subjectDN());

    //  ------------------------------------------------------------------------
    //  Do the equivalent using GetServerCert.
    //  Your application creates a new, empty certificate object which is passed 
    //  in the last argument and filled with the server certificate upon success.

    CkCert cert2 = new CkCert();
    success = http.GetServerCert(domain,port,cert2);
    if (success == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println(cert2.subjectDN());
  }
}