Java Requires Chilkat v11.0.0+
Chilkat2 Java
Get Certificate Public Key from PEM
See more Certificates Examples
Demonstrates how to load a PEM file containing a certificate and access the public key.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.Cert;
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.PublicKey;
public class ChilkatExample {
public static void main(String[] args) {
Cert cert = new Cert();
try {
cert.loadFromFile("qa_data/pem/my_cert.pem");
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
PublicKey pubkey = new PublicKey();
cert.getPublicKey(pubkey);
// Examine the public key as XML..
System.out.println(pubkey.getXml());
}
}