A MIME message can have multiple signers and information about them is available in MimeMessage
/MimeEntity
's SignedContentInfo.SignerInfos
collection. Each signer has an associated certificate chain which should contain the root certificate.
For example, to get root certificate of the first signer, use the following code:
Certificate rootCertificate = _mimeMimeMessage.SignedContentInfo.SignerInfos[0].CertificateChain.RootCertificate
Please note that CertificateChain
might be null
if the certificates were not embedded in the message and not present in local certificate stores. Also, the chain might be incomplete, which would result in RootCertificate
being null
. I have not included checks for these conditions in the sample code above for simplicity.