2013-10-14 81 views
0

我想將以下Java代碼轉換爲iOS。請幫助我。從已簽名的信封數據獲取X509證書

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中實現同樣的事情?

回答

0

在Security.framework中檢出CMSDecoder.h。這加上你開始的openssl框架。

WRONG
Cryptographic Message Syntax API是不公開的iOS上。我想它一直是openssl。抱歉!

+0

看起來CMS CMS現已公開:https://developer.apple.com/library/mac/documentation/security/Reference/CryptoMessageRef/Reference/reference.html#//apple_ref/doc/uid/TP40006264 –

+0

它在MacOSX上公開,但不在iOS上。 –