从签名的包络数据中获取X509证书

时间:2013-10-14 09:50:19

标签: ios objective-c openssl

我想将以下Java代码转换为iOS。请帮帮我。

CMSSignedDataParser sp = new CMSSignedDataParser(new JcaDigestCalculatorProviderBuilder().setProvider("BC").build(), contents.getBuffer());

sp.getSignedContent().drain();

Store                   certStore = sp.getCertificates();
SignerInformationStore  signers = sp.getSignerInfos();

Collection              c = signers.getSigners();
Iterator                it = c.iterator();

while (it.hasNext())
{
    SignerInformation   signer = (SignerInformation)it.next();
    Collection          certCollection = certStore.getMatches(signer.getSID());

    Iterator        certIt = certCollection.iterator();
    X509CertificateHolder cert = (X509CertificateHolder)certIt.next();
    X509Certificate certificate = new JcaX509CertificateConverter().setProvider( "BC" ).getCertificate( cert );
}

这里用Java从签名信息中提取X509证书。如何在iOS中实现相同的功能?

1 个答案:

答案 0 :(得分:0)

在Security.framework中查看CMSDecoder.h。加上openssl框架,你就可以开始了。

<强> WRONG
Cryptographic Message Syntax API在iOS上不公开。我想它一直都是openssl。遗憾!