Java Requires Chilkat v11.0.0+
Chilkat2 Java
Get Certificate's Public Key
Loads a certificate from PEM and gets 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();
String strPem = "-----BEGIN CERTIFICATE----- ...";
try {
cert.loadPem(strPem);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
PublicKey pubKey = new PublicKey();
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());
}
}