Question

Hi I was wondering how you would verify that a PublicKey belongs to a certain individual or party during an RSA key exchange using a Certificate in java ? I need to know how to do this any help would be much appreciated and if you could provide a code example that would be awesome, thanks :) Also How do I create a Certificate object as I don't have a certificate file either ?

P.S. My RSA keys are generated as shown for both sides

KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
KeyPair kp = kpg.generateKeyPair();
PrivateKey pvtKey = kp.getPrivate();
PublicKey pubKey = kp.getPublic();
Was it helpful?

Solution

This is BouncyCastle cryptography library's example, how to create different certificates in Java. If you don't have any other key pair as mentioned, you will be able to produce only self-signed certificates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top