Jeton seri durumdan çıkarılırken bir istisna atıldı. Antiforgery jetonunun .Net Core 2.2 uygulamasında şifresi çözülemedi.
Günlüğümde hata alıyorum. Günümün çoğunu çözümü bulmak için harcadım ama ihtiyacımı karşılayanı bulamadım.
İşte günlük hatası
önem = [HATA], ipaddress = xxxx, subprocess = Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery, description = Belirteç seri durumdan çıkarılırken bir istisna atıldı. Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: Antiforgery belirtecinin şifresi çözülemedi. ---> System.Security.Cryptography.CryptographicException: Anahtar halkasında {xxxxxxxxxx} anahtarı bulunamadı. Microsoft. ) Microsoft.AspNetCore.DataProtection.KeyManagement.Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgeryTokenSerializer.Deserialize (String serializedToken) at KeyRingBasedDataProtector.Unprotect (Byte [] protectedData). DefaultAntiforgery.GetCookieTokenDoesNotThrow (HttpContext httpContext)
"Certificates": {
"StoreName": "My",
"StoreLocation": "LocalMachine"
"SerialNumber": "xxxxxxxxxxxx"
},
private X509Certificate2 LCertificate()
{
var storeName = Configuration["Certificates:StoreName"];
var storeLocation = Configuration["Certificates:StoreLocation"];
string serialNumber = Configuration["Certificates: SerialNumber"];
using(X509Store store = new X509Store(storeName,storeLocation))
{
var certificates = store.Certificates
.Find(X509FindType.FindBySerialNumber,
serialNumber,
acceptValidCertOnly);
return certificates[0];
}
}
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentityServer
.AddSigningCredential(new X509Certificate2(LCertificate()))
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Login(LoginModel model)
{
Yanıtlar
Eğer
- uygulamanız birden çok sunucuda barındırılıyor
- paylaşılan veri korumasını yapılandırmadı
- yapışkan oturumlar kullanmıyorsun
bu, kullanıcı A sunucusundan form içeren bir sayfa istediğinde ve daha sonra formu B sunucusuna gönderdiğinde gerçekleşir.
Ayrıca, tek bir IIS sunucusunda da olabilir
- kullanıcı, form içeren bir sayfa ister
- sunucuyu yeniden başlat
- kullanıcı formu gönderir
Bunun nedeni, yeniden başlatma işleminin yeni bir anahtarlığın belleğe yüklenmesine neden olması ve form içindeki antiforgery anahtarının artık doğrulanmamasıdır.
İkinci durum, IIS'de uygulama havuzunda "kullanıcı profilini yükle" seçeneği işaretlenerek düzeltilebilir.
Daha fazla bilgi: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-3.1