android - 使用 mimekit 在 xamarin 中为 android 和 iOS 读取 p7m 文件
问题描述
我正在尝试使用 bouncycastle 和 mimekit 在 Xamarin android 中为 Android 解密 .P7M 文件。当我点击“ApplicationPkcs7Mime p7m = new 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 文件的经验?
多谢