質問

In .NET there is a method available to get a byte array of a certificate. However, in a Windows Store App, you would not find this Export() method...

This is how it's done in regular .NET:

// .NET 4.5
X509Certificate cert = new X509Certificate("path/to/cert.pfx");
byte[] certData = cert.Export(X509ContentType.Cert);



How can you export a certificate as a byte array in a Windows Store App?

役に立ちましたか?

解決

There is a new method in the .NET for Windows Store Apps: Certificate.GetCertificateBlob()
It returns a BLOB which you can then transform into an array to get your byte array

// get certificate with given Friendly Name
var query = new CertificateQuery { FriendlyName = "certFriendlyName" };
certList = await CertificateStores.FindAllAsync(query);
Certificate cert = certList.First();

// get the BLOB of the certificate and transform it to byte[]
var blob = cert.GetCertificateBlob();
byte[] certData = blob.ToArray();

Also look here for more Information:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.security.cryptography.certificates.certificate.getcertificateblob

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top