2016-07-04 75 views
0

我使用SignalR 2.2.0和MVC 4。当我打开我的Chrome浏览器网页,我收到一个错误在控制台:SignalR - 指定的解密密钥无效的十六进制字符

http://localhost:8180/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&_=1467627883530 500 (Internal Server Error) 

经进一步检查使用菲德勒我可以查看堆栈跟踪:

[ConfigurationErrorsException]: Decryption key specified has invalid hex characters. (C:\Users\Foo\web.config line 66) 

    at System.Web.Security.Cryptography.MachineKeyMasterKeyProvider.GenerateCryptographicKey(String configAttributeName, String configAttributeValue, Int32 autogenKeyOffset, Int32 autogenKeyCount, String errorResourceString) 
    at System.Web.Security.Cryptography.MachineKeyMasterKeyProvider.GetEncryptionKey() 
    at System.Web.Security.Cryptography.Purpose.GetDerivedEncryptionKey(IMasterKeyProvider masterKeyProvider, KeyDerivationFunction keyDerivationFunction) 
    at System.Web.Security.Cryptography.AspNetCryptoServiceProvider.GetNetFXCryptoService(Purpose purpose, CryptoServiceOptions options) 
    at System.Web.Security.Cryptography.AspNetCryptoServiceProvider.GetCryptoService(Purpose purpose, CryptoServiceOptions options) 
    at System.Web.Security.MachineKey.Protect(ICryptoServiceProvider cryptoServiceProvider, Byte[] userData, String[] purposes) 
    at System.Web.Security.MachineKey.Protect(Byte[] userData, String[] purposes) 
    at Microsoft.Owin.Host.SystemWeb.DataProtection.MachineKeyDataProtector.Protect(Byte[] userData) 
    at Microsoft.Owin.Security.DataProtection.AppBuilderExtensions.CallDataProtectionProvider.CallDataProtection.Protect(Byte[] userData) 
    at Microsoft.AspNet.SignalR.Infrastructure.DataProtectionProviderProtectedData.Protect(String data, String purpose) 
    at Microsoft.AspNet.SignalR.PersistentConnection.ProcessNegotiationRequest(HostContext context) 
    at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context) 
    at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context) 
    at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(IDictionary`2 environment) 
    at Microsoft.AspNet.SignalR.Owin.Middleware.HubDispatcherMiddleware.Invoke(IOwinContext context) 
    at Microsoft.Owin.Infrastructure.OwinMiddlewareTransition.Invoke(IDictionary`2 environment) 
    at Microsoft.Owin.Mapping.MapMiddleware.<Invoke>d__0.MoveNext() 

从我收集的,SignalR使用机器的关键部分进行加密/解密。

这是机器的关键看起来像什么:

<machineKey decryptionKey="5E329ED7DE2786FCD906E717C97A09BE26B3564BBE0A2B28,IsolateApps" validationKey="A64F709FB47B282CB8331205BC423D63450B4FFC92FE06EC1E00B3AE8B5B1F529A5CD1064F66C08545FC13B013F84153598B29213D5494DD5EC348B537A51DAE,IsolateApps"/> 

我猜它看到“IsolateApps”在decryptionKey /的validationKey和抛出异常(“...无效的十六进制字符”)。

如果我从密钥中删除“IsolateApps”,我无法再登录,因为我使用的是FormsAuthentication,后者又使用密钥来加密/解密。因此,删除“IsolateApps”似乎不是一个解决方案。

PS。我使用的代码是this教程。 我已经看过this answer但它不能解决问题。我也尝试将compatibilityMode="Framework20SP1"添加到机器密钥中,但这也不起作用。

有没有办法解决这个问题,而无需从网络配置中的键删除“IsolateApps”值?

回答

1

我已经解决了这个问题。我决定删除该停止给该异常的机键“,IsolateApps”属性:

Decryption key specified has invalid hex characters

删除此属性意味着我无法登录了(因为机器密钥技术上改变),这迫使我重新设置我的帐户密码。有一次,我重置密码,我可以记录继续

一旦我能登录,我收到此错误:

ws://xxxxx/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=xxxxx' failed: Connection closed before receiving a handshake response.

此异常只被在Chrome中抛出。

由于web套接字握手不成功,SignalR回退到服务器发送的事件。几个小时的调试后,我加入这web配置解决了这个问题:

<system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    <pages controlRenderingCompatibilityVersion="4.0" /> 
</system.web> 

一旦加入,SignalR被用作除外。

+0

删除IsolateApps为我工作,所以谢谢。不过,在进行配置更改后,我仍然回落到SSE。 :( –

相关问题