使用mimekit在xamarin中为Android和iOS读取p7m文件

时间:2019-03-07 10:09:30

标签: android xamarin bouncycastle smime mimekit

我正在尝试使用bouncycastle和mimekit在Xamarin android中解密Android的.P7M文件。当我打             “” ApplicationPkcs7Mime p7m =新的ApplicationPkcs7Mime(SecureMimeType.EnvelopedData,ms)“;

Android仿真器不知道如何从Android证书存储区或USB卡读取器中调用它。

       public class CustomBouncyCastleSecureMimeContext : BouncyCastleSecureMimeContext
      {
          public CustomBouncyCastleSecureMimeContext() : base()
          {
          }}

更新的代码

        System.Diagnostics.Debug.WriteLine("Inside DecryptMime");
        CryptographyContext.Register(typeof(BouncyCastleSecureMimeContext));
        // Payload from the add-in contains the mime content of the email on base-64 encoding   

        byte[] bytes = ResourceLoader.GetEmbeddedResourceBytes(Assembly.GetAssembly(typeof(ResourceLoader)), "smime.p7m");
        MemoryStream ms = new MemoryStream(bytes);
        ApplicationPkcs7Mime p7m = new ApplicationPkcs7Mime(SecureMimeType.EnvelopedData, ms);

        // parse data as cms enveloped
        CmsEnvelopedDataParser edParser = new CmsEnvelopedDataParser(bytes);

        // reiterate inside to find recipient info
        ICollection collections = edParser.GetRecipientInfos().GetRecipients();
        IEnumerator it = collections.GetEnumerator();
        while (it.MoveNext())
        {
            RecipientInformation info = (RecipientInformation)it.Current;
        }

有人在阅读android中的P7M文件方面有经验吗?

非常感谢

0 个答案:

没有答案