I have developed one application in .net 3.5 framework and consuming web service through it using below code
In our development application it's running fine but when I have deployed it in production environment It's giving me an error. I have tested it in three different OS Windows 7, Windows Server 2008 R2 and Windows Server 2003 R2
System.NotSupportedException: The requested security protocol is not supported.
Do I need to install any additional software or patch?
I have gone through
Microsoft Support[
^]
But when I install this patch I am getting error "This patch is not applicable to your system"
What I have tried:
Module SslProtocolsExtensions
Public Const Tls12 As SslProtocols = CType(&HC00, SslProtocols)
Public Const Tls11 As SslProtocols = CType(&H300, SslProtocols)
End Module
Module SecurityProtocolTypeExtensions
Public Const Tls12 As SecurityProtocolType = CType(SslProtocolsExtensions.Tls12, SecurityProtocolType)
Public Const Tls11 As SecurityProtocolType = CType(SslProtocolsExtensions.Tls11, SecurityProtocolType)
Public Const SystemDefault As SecurityProtocolType = CType(0, SecurityProtocolType)
End Module
Dim response As String
Dim client As New WebClient()
Dim credentials As String
credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("XXXX" + ":" + "XXXX"))
client.Headers.Add("Authorization", "Basic " & credentials)
client.Headers.Add(HttpRequestHeader.ContentType, "application/xml")
If blnCookie Then
client.Headers.Add(HttpRequestHeader.Cookie, strCookie)
End If
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or SecurityProtocolType.Ssl3 Or SecurityProtocolTypeExtensions.Tls11
Try
Dim strEaushadhiURI = "https://XXXXXXXXXXX/AMH/1031180700004"
System.Net.ServicePointManager.ServerCertificateValidationCallback = _
Function(se As Object, _
cert As System.Security.Cryptography.X509Certificates.X509Certificate, _
chain As System.Security.Cryptography.X509Certificates.X509Chain, _
sslerror As System.Net.Security.SslPolicyErrors) True
response = client.DownloadString(New Uri(strEaushadhiURI))
System.Net.ServicePointManager.ServerCertificateValidationCallback = Nothing
TextBox1.Text = response
Catch ex As WebException
Throw ex
End Try