static RSA GetKeyMatchingCertificate(MSX.PKCS12 pfx, MSX.X509Certificate cert) { IDictionary attributes = pfx.GetAttributes(cert); return(pfx.GetAsymmetricAlgorithm(attributes) as RSA); }
public void GetAsymmetricAlgorithm_Test () { PKCS12 p12 = new PKCS12 (); IDictionary attrs = new Hashtable (); ArrayList attrValues = new ArrayList (); attrValues.Add (Encoding.BigEndianUnicode.GetBytes ("Friendly name")); attrs.Add (PKCS9.friendlyName, attrValues); p12.AddKeyBag (RSA.Create (), attrs); AssertEquals ("GA.1", p12.Keys.Count, 1); AsymmetricAlgorithm aa = p12.GetAsymmetricAlgorithm (attrs); AssertNotNull ("GA.2", aa); }