Java Bouncy Castle 1.47 を使用して、署名者の X509CertificateObject を CMSSignedData オブジェクトから抽出しようとしています。これまでのところ、org.bouncycastle.asn1.x509.Certificate オブジェクトしか抽出できませんでした。これから X509CertificateObject を取得するにはどうすればよいですか? どうもありがとう!
public static X509CertificateObject extractSignersCert(CMSSignedData cmsSignedData)
throws Exception
{
SignerInformationStore signerInfoStore;
SignerInformation signerInfo;
Store certStore;
Collection certCollection;
X509CertificateHolder x509CertHolder;
X509Certificate cert;
X509CertificateObject certObj;
JcaX509CertificateConverter certConverter;
signerInfoStore = cmsSignedData.getSignerInfos();
signerInfo = (SignerInformation) signerInfoStore.getSigners().iterator().next();
certStore = cmsSignedData.getCertificates();
certCollection = certStore.getMatches(signerInfo.getSID());
x509CertHolder = (X509CertificateHolder) certCollection.iterator().next();
certConverter = new JcaX509CertificateConverter();
certConverter.setProvider("BC");
cert = certConverter.getCertificate(x509CertHolder);
certObj = (X509CertificateObject) cert;
return certObj;
}