Code example for X509Certificate

Methods: getPublicKey

0
		KeyPair ecKeyPair = RSAKeyPairGenerator.generateRSAKeyPair(1024, RSAKeyGenParameterSpec.F4);
		 
		//when 
		X509Certificate certificate = rsaCertificateCreator.createSelfSignedCertificate(ecKeyPair, "SHA1withRSA");
		RSAPublicKey pairRSAPublicKey = (RSAPublicKey) ecKeyPair.getPublic();
		RSAPublicKey certRSAPublicKey = (RSAPublicKey) certificate.getPublicKey();
		 
		// then 
		Assertions.assertThat(certRSAPublicKey.getModulus()).isEqualTo(pairRSAPublicKey.getModulus());
	} 
 
} 
Connect your IDE to all the code out there  Get Codota for Java