Sample code for 30+ languages & platforms
Java

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

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;

    CkCert cert = new CkCert();

    String strPem = "-----BEGIN CERTIFICATE----- ...";

    success = cert.LoadPem(strPem);
    if (success == false) {
        System.out.println(cert.lastErrorText());
        return;
        }

    CkPublicKey pubKey = new CkPublicKey();
    cert.GetPublicKey(pubKey);

    //  You can now use the public key object however it is needed,
    //  and access its various properties and methods..

    System.out.println(pubKey.getXml());
  }
}