Я хочу создать CX509CertificateRequestPkcs с initializefromcertificate. И я хочу использовать X509RequestInheritOptions.InheritNewS Similarkeykey для создания новой пары ключей, в которой исходная пара ключей Certificate'Sexit, но я получаю ошибку CertEnroll :: CX509CertificateRequestPromcser. Запрошенное значение: 0x80094004 (-2146877436 CERTSRV_E_PROPERTY_EMPTY) "Это мой код
X509Store store = new X509Store(StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
foreach (X509Certificate2 c in store.Certificates)
{
var cert2 = c.Subject;
if (cert2.Contains("CN=test"))
{
var objPkcs72 = new CX509CertificateRequestPkcs7();
string strCertificate = Convert.ToBase64String(c.RawData);
var inheritOptions = X509RequestInheritOptions.InheritNewSimilarKey ;
objPkcs72.InitializeFromCertificate(X509CertificateEnrollmentContext.ContextUser, false, strCertificate, EncodingType.XCN_CRYPT_STRING_BASE64, inheritOptions);
ISignerCertificate signer = new CSignerCertificate();
CERTENROLLLib.CSignerCertificate signer2 = new CERTENROLLLib.CSignerCertificate();
signer2.Initialize(false, X509PrivateKeyVerify.VerifyAllowUI, EncodingType.XCN_CRYPT_STRING_BASE64, strCertificate);
objPkcs72.SignerCertificate = signer2;
string c2 = "";
objEnroll.InitializeFromRequest(objPkcs72);
var message2 = objEnroll.CreateRequest(EncodingType.XCN_CRYPT_STRING_BASE64);
var iDisposition = objCertRequest.Submit(CR_IN_BASE64 | CR_IN_FORMATANY, message2, templateName, CAAddress);
string c3 = objCertRequest.GetCertificate(CR_IN_BASE64 | CR_IN_FORMATANY);
X509Certificate2 cert = new X509Certificate2(LoadFromCertBase64String(c2));
objEnroll.InstallResponse(InstallResponseRestrictionFlags.AllowNone, c3, EncodingType.XCN_CRYPT_STRING_BASE64, "");
}
}