Hi all,
I'm looking at code to decrypt an email message at the moment and I came accross the following lines of code:
Certificate returnedCert = keystore.getCertificate(alias);
RecipientId recId = new RecipientId();
recId.setSerialNumber(((X509Certificate) returnedCert).getSerialNumber());
recId.setIssuer(((X509Certificate) returnedCert).getIssuerX500Principal().getEncoded());
I'm not sure what the RecipientId object does here. Why does it take information from my private key? I was under the impression that I would use my private key to decrypt emails sent to me which were encrypted using my public key. But then these lines:
//Partner's public key alias defined in property file
String keyAlias = owner.getProperty(PropNames.KEY_PUBLIC_ALIAS);
MimeBodyPart res = SMIMEUtil.toMimeBodyPart(recipient.getContent(keystore.getKey(keyAlias, null),"BC"));
seems to be using the senders public key to do something! Any help appreciated!
Thanks,
Illu