zoukankan      html  css  js  c++  java
  • Error unprotecting the session cookie.The payload was invalid.

     .Net Core 3.0

    warn: Microsoft.AspNetCore.Session.SessionMiddleware[7]
          Error unprotecting the session cookie.
    System.Security.Cryptography.CryptographicException: The payload was invalid.
       at Microsoft.AspNetCore.DataProtection.Cng.CbcAuthenticatedEncryptor.DecryptImpl(Byte* pbCiphertext, UInt32 cbCiphertext, Byte* pbAdditionalAuthenticatedData, UInt32 cbAdditionalAuthenticatedData)
       at Microsoft.AspNetCore.DataProtection.Cng.Internal.CngAuthenticatedEncryptorBase.Decrypt(ArraySegment`1 ciphertext, ArraySegment`1 additionalAuthenticatedData)
       at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
       at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte[] protectedData, Boolean ignoreRevocationErrors, Boolean& requiresMigration, Boolean& wasRevoked)
       at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
       at Microsoft.AspNetCore.Session.CookieProtection.Unprotect(IDataProtector protector, String protectedText, ILogger logger)

    漏加了 services.AddDataProtection()

    public void ConfigureServices(IServiceCollection services)
    {
    
        services.AddSession(); 
        services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "DataProtection"));
        
        services.AddRazorPages().AddRazorRuntimeCompilation();
        services.AddControllersWithViews(); 
    }
    
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    { 
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            app.UseStatusCodePagesWithReExecute("/Home/Error");
        }
    
        app.UseSession(); 
    }

  • 相关阅读:
    20000字干货笔记,一天搞定Mysql~【转】
    Linux操作系统概述及内核介绍
    如何在装有高版本NBU的主机上安装低版本的NBU?卸载8.0安装7.5记录
    vmware+kvm+vnc安装配置
    NBU异机恢复Oracle数据库,作业报错2850处理
    NetBackup 进程整理
    1、虚拟化实施流程、宿主机如何选型、如何进行性能测试
    灾难恢复的衡量指标RTO和RPO
    国内主要灾备厂商
    单例设计模式
  • 原文地址:https://www.cnblogs.com/vipsoft/p/13045581.html
Copyright © 2011-2022 走看看