6

My question is simple, I have read these two main pages :

But from the first link, it's showing configuration for SecurityProtocol set in global.asax.cs for solving

"System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel."

Here, I want this config is set in web.config / app.config, just for making it a little specific for own project not for all asp.net projects... Then I think the second link {msdn.microsoft.com.....} is the way, but the SSL/TLS error is still there... So my question how to implement following through web.config?

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
        | SecurityProtocolType.Tls11
        | SecurityProtocolType.Tls12
        | SecurityProtocolType.Ssl3;

I have read this page too Force by config to use tls 1.0 in a wcf client c#, but there are no answers.

and then... I just found these pages :

then I implement my custom binding like this :

<customBinding >
      <binding name="SureTaxSoap">                  
           <sslStreamSecurity requireClientCertificate="true"   sslProtocols="Ssl3|Tls|Tls11|Tls12" >                    
                </sslStreamSecurity>
            </binding>
</customBinding>

but sslProtocols="Ssl3|Tls|Tls11|Tls12" is unidentified

itsrizi
  • 201
  • 3
  • 10
Maryadi Poipo
  • 1,418
  • 8
  • 31
  • 54
  • Side note: "global.asax.cs" is ASP.Net web site specific file (usually equals to single Visual Studio project)... Not sure what " specific for own project not for all asp.net projects" refers too - you may want to clarify what do you mean by "project" (which seem to be different from Visual Studio project) – Alexei Levenkov Jan 27 '16 at 03:32
  • mmmm...... okie lemme talk a little.. :) I have some projects on visual studio, may be about 24 projects and just project has global.asax.cs, another project just has app.config....the main project is the one that has that global.asax file... :) – Maryadi Poipo Jan 27 '16 at 04:01
  • I found these link : https://msdn.microsoft.com/en-us/library/ms731377(v=vs.100).aspx Then I implement my custom binding like this : But visual studio gives the message error about "sslProtocols="Ssl3|Tls|Tls11|Tls12" is invalid... – Maryadi Poipo Jan 27 '16 at 04:03

3 Answers3

5

Typically, enums are converted from strings in the web.config, using Enum.Parse or Enum.TryParse. I expect (but have not checked the reference source to confirm) that the same is true for the WCF settings.

Enum.Parse uses a comma to separate flags-based enum values, but can also parse the equivalent integer values as strings, if need be.

Therefore, if your problem is concatenating the flags-based enum values in the web.config setting, you may be able to do so using comma to separate, e.g.:

sslProtocols="SSl3, Tls"
sslProtocols="SSl3, Tls, Tls11, Tls12"

Or, if your problem is that Tls12 is not a recognised value, then this was only added in .NET 4.5. If you are compiling for .NET 4.0, then it won't parse as a named enum. However, .NET 4.5 is an in-place update to 4.0, so if you have 4.5 installed you may be able to parse the numeric value:

sslProtocols="4080"

This is taken from the sum of all the numeric values for the System.Net.SecurityProtocolType enum. These numeric values are also the same as the values in System.Security.Authentication.SslProtocols and System.IdentityModel.SchProtocols, so I'm going to guess that they are the same in your case.

Ssl3 = 48,
Tls = 192,
Tls11 = 768,
Tls12 = 3072

Of course, if it is available to you, it might be cleaner to upgrade to at least Visual Studio 2012 / .NET 4.5, where the named strings should become available.

jimbobmcgee
  • 1,561
  • 11
  • 34
0

I have experienced the same and I made it work by using only one SSL/TLS protocol.

For example, sslProtocols="Tls12", if you need the strongest security protocol.

Otherwise, if we don't need to specify SSL Protocol, the default will be TLS1 in .Net4.5

Joe Park
  • 77
  • 1
  • 6
  • The problem is SslProtocols="Tls12" is undefined in my web.config – Maryadi Poipo Jan 27 '16 at 06:57
  • @HyosokaPoipo The TLS 1.2 option was introduced in .NET Framework 4.5, so you will need an alternative syntax if you're using 4.0. See jimbobmcgee's answer for more detailed information. – Suncat2000 Jun 05 '19 at 12:39
0

sslProtocols="Ssl3|Tls|Tls11|Tls12"is invalid(in web.config) in Visual Studio 2012(.Net Framework 4.5)

But it is available in Visual Studio 2015(.Net Framework 4.5.2)

Palash
  • 26
  • 4