How to Set TLS 1.2 in web.config in asp.net webform

2.2k Views Asked by At

I am not sure if there is a way to add TLS 1.2 or TLS 1.1 in ` in web.config file.

In code i can add it as

 System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

I am not sure how we can add it in Web.config file so that it can be used by mailSettings

<mailSettings>  
      <smtp from="[email protected]">  
        <network  
          host="outlook.office365.com"  
          port="587"  
           enableSsl="true"
          userName="[email protected]"  
          password="somepassword"
        />  
      </smtp>  
    </mailSettings>  

I need this to work in web.config file as hosting provider has disabled TLS 1.0 and now whenever we are trying to submit any form we get error related to SSL which is due to host doesnt support TLS1.0 .. so i made changes in code for some forms as

 System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

but password reset function which uses default mailsetting from web.config are still giving errors related to SSL as i am not sure how i can force TLS 1.2 in web.config

0

There are 0 best solutions below