Azure / aspnet-redis-providers

ASP.NET Redis Providers
Other
269 stars 181 forks source link

Exception: The specified value is not valid in the 'SslProtocolType' enumeration #189

Closed timomta closed 1 year ago

timomta commented 1 year ago

Hello,

I am porting a customer .Net FW 4.8 app out to Azure and it uses session state. I've been struggling to get the Redis provider to work. I'm using 5.0.0 of the session state package. It pulls in the StackExchange.Redis 2.6.96 package and I tried updating it to 2.6.111, but I get the same error.

       <Data>RedisConnectionException</Data>
        <Data>InternalFailure on {my cache server}.redis.cache.usgovcloudapi.net:6380/Interactive, Initializing/NotStarted, last: NONE, origin: ConnectedAsync, outstanding: 0, last-read: 0s ago, last-write: 0s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.6.111.64013

The specified value is not valid in the 'SslProtocolType' enumeration. Parameter name: sslProtocolType at System.Net.Security.SslState.ValidateCreateContext(Boolean isServer, String targetHost, SslProtocols enabledSslProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, Boolean remoteCertRequired, Boolean checkCertRevocationStatus, Boolean checkCertName) at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) at StackExchange.Redis.ExtensionMethods.AuthenticateAsClient(SslStream ssl, String host, Nullable`1 allowedProtocols, Boolean checkCertificateRevocation) at StackExchange.Redis.PhysicalConnection.<ConnectedAsync>d__106.MoveNext()

The application is set to use Tls 1.2 in Global.asax:Application_Start with ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

The Redis server is set to require Tls 1.2 Advanced Settings Minimum TLS version.

I can't seem to get past this or see what is wrong. Any ideas?

philon-msft commented 1 year ago

Does the Redis connection string specify an sslProtocols setting? Configuration options docs here, valid values here

If that doesn't point to a solution, this may be a question for the https://github.com/StackExchange/StackExchange.Redis repo

timomta commented 1 year ago

Thanks! I really appreciate those references. In my case, I narrowed it down to configuration discrepancy between the runtime and compilation frameworks. I set them the same:

<httpRuntime targetFramework="4.8.1" />

Since it was an old app, they were set to different values, which apparently wasn't friendly to the StackExchange client. Setting them both to the same Framework version cleared up the failures.

timomta commented 1 year ago

Resolved (configuration issue) by setting system.web compilation and httpRuntime to the same framework versions.