public void Create_Attributes() { var ChallengePasswordAttribute = new X509ChallengePasswordAttribute("password"); var EnrollmentNameValuePairAttribute = new X509EnrollmentNameValuePairAttribute(new X509EnrollmentNameValuePairParams() { CertificateUsage = (new List <Oid>() { new Oid("1.2.3.4"), new Oid("2.3.4") }).ToArray() }); var EnrollmentNameValuePairAttribute2 = new X509EnrollmentNameValuePairAttribute(new X509EnrollmentNameValuePairParams() { Other = "test" }); var param = new CertificateRequestParams() { Attributes = new Attribute[] { ChallengePasswordAttribute, EnrollmentNameValuePairAttribute, EnrollmentNameValuePairAttribute2 } }; var key = RSA.Create(); key.ExportParameters(true); var req = new Pkcs10CertificateRequest(param, key); Assert.True(req.Verify()); var lapo = Convert.ToBase64String(req.RawData); }
/// <summary> /// Qualification of attribute by type /// </summary> /// <param name="asn1Encodable"></param> /// <returns></returns> private Attribute QualificationAttribute(Asn1Encodable asn1Encodable) { var attr = new Attribute(asn1Encodable.GetEncoded()); switch (attr.Type.Value) { case OidAttributes.СhallengePassword: attr = new X509ChallengePasswordAttribute(asn1Encodable.GetEncoded()); break; case OidAttributes.EnrollmentNameValuePair: attr = new X509EnrollmentNameValuePairAttribute(asn1Encodable.GetEncoded()); break; default: break; } return(attr); }