Код: Выделить всё
using var rsa = RSA.Create(4096);
var certificateRequest = new CertificateRequest("CN=testCertificate", rsa, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
// Make sure the key can only be used for encryption purposes
certificateRequest.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.EncipherOnly, true));
var selfSignedCertificate = certificateRequest.CreateSelfSigned(DateTimeOffset.Now, DateTimeOffset.Now.AddYears(1));
using var exportedCertificate = new X509Certificate2(selfSignedCertificate.Export(X509ContentType.Pfx));
var x509PublicKey = Convert.ToBase64String(exportedCertificate.GetPublicKey());
var rsaPrivateKey = Convert.ToBase64String(rsa.ExportRSAPrivateKey());
- Использовать разные алгоритмы хеширования
- Не указывать X509KeyUsageExtension
- Экспорт сертификата как X509ContentType.Cert и использование его в качестве открытого ключа
Код: Выделить всё
var requestBody = new Subscription
{
ChangeType = "created,updated",
NotificationUrl = _notificationUrl,
LifecycleNotificationUrl = _lifecycleUrl,
Resource = resource,
ExpirationDateTime = DateTime.UtcNow.AddDays(3),
ClientState = _clientState,
IncludeResourceData = true,
EncryptionCertificate = x509PublicKey,
EncryptionCertificateId = certificateId
};
graphClient.Subscriptions.PostAsync(requestBody, cancellationToken: cancellationToken);
Код: Выделить всё
EncryptionCertificate
Ошибка проверки сертификата: невозможно найти запрошенный сертификат. объект.
Если у кого-нибудь есть идеи или примеры того, как обойти эту ошибку, мы будем очень признательны.
Подробнее здесь: https://stackoverflow.com/questions/786 ... rp-x509cer