synercoder / FormsAuthentication

Enable ASP.NET Core 2 cookies to read old ASP.NET Forms Authentication cookies
MIT License
74 stars 25 forks source link

CryptographicException #1

Closed aleksmudric closed 6 years ago

aleksmudric commented 6 years ago

Hi, I have two apps web apps (first is .net 4.5 and second one is .net core 2). I want to share cookie that is set in first one and to read it in second one. I keep getting CryptographicException for some reason... I tried your example and every thing works as expected. Can you please point me in right direction to try to find solution for my problem?

Here are my configurations: .net 4.5

<machineKey
    validationKey="F2D27DF0348E9A3EAD6AC66330C31F821394D4CD1A5E139EEE85EA9D9F2A963E55EC87572F699FB834292CC9E37AD56B6B26AA379106CBA5E9AA544C688F3E92"
    decryptionKey="F6D5A5C8DDEC57481610829F58D6C95BDAC5FA21082F3FA9CB5A36DCEAACBEDB" validation="SHA1"
            decryption="AES"
        />
        <compilation targetFramework="4.5" debug="true" />
        <authentication mode="Forms">
            <forms name=".ezesuite" protection="All" loginUrl="~/Account/Login" timeout="1440" requireSSL="false" slidingExpiration="true" ticketCompatibilityMode="Framework40" path="/" domain="" />
        </authentication>

.net core 2


"FormsAuthentication": {
        "CookieName": ".ezesuite",
        "BaseAuthUrl": "http://mysite.staging.com",
        "DecryptionKey": "F6D5A5C8DDEC57481610829F58D6C95BDAC5FA21082F3FA9CB5A36DCEAACBEDB",
        "ValidationKey": "F2D27DF0348E9A3EAD6AC66330C31F821394D4CD1A5E139EEE85EA9D9F2A963E55EC87572F699FB834292CC9E37AD56B6B26AA379106CBA5E9AA544C688F3E92",
        "EncryptionMethod": "AES",
        "ValidationMethod": "SHA1"
    }
aleksmudric commented 6 years ago

In case someone is having same problem, solution for me was to explicitly add
<httpRuntime maxRequestLength="20000000" executionTimeout="1800" enableVersionHeader="false" targetFramework="4.5"/> in my web.config of the .net 4.5 project.