import java.security.PublicKey; ... PublicKey publicKey = MyClass.class.getProtectionDomain().getCodeSource().getCertificates()[0].getPublicKey();