J'ai une ancienne application vb.net Visual Studio 2010 dont j'ai besoin pour mettre à jour la canalisation SSL TLS afin de prendre en charge TLS 1.2. J'ai essayé quelques options différentes (voir le code commenté pour les tentatives) et tout me conduit à la même erreur, "Impossible de créer un canal sécurisé SSL/TLS." Qu'est-ce que je rate?SSL TLS 1.2 Création de canal VB.net HTTPS WebRequest
Public Shared Function processCCRequest(ByVal strRequest As String) As String
'declare the web request object and set its path to the PayTrace API
Dim ThisRequest As WebRequest = WebRequest.Create("https://beta.paytrace.com/api/default.pay")
'configure web request object attributes
ThisRequest.ContentType = "application/x-www-form-urlencoded"
ThisRequest.Method = "POST"
'encode the request
Dim Encoder As New System.Text.ASCIIEncoding
Dim BytesToSend As Byte() = Encoder.GetBytes(strRequest)
'declare the text stream and send the request to PayTrace's API
Dim StreamToSend As Stream = ThisRequest.GetRequestStream
StreamToSend.Write(BytesToSend, 0, BytesToSend.Length)
StreamToSend.Close()
''ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
''allows for validation of SSL conversations
''ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf)
ServicePointManager.Expect100Continue = True
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
''| SecurityProtocolType.Tls11 | SecurityProtocolType.Tls
''var(response = WebRequest.Create("https://www.howsmyssl.com/").GetResponse())
''var(body = New StreamReader(response.GetResponseStream()).ReadToEnd())
'Catch the response from the webrequest object
Dim TheirResponse As HttpWebResponse = ThisRequest.GetResponse
Dim sr As New StreamReader(TheirResponse.GetResponseStream)
Dim strResponse As String = sr.ReadToEnd
'Out put the string to a message box - application should parse the request instead
' MsgBox(strResponse)
sr.Close()
Return strResponse
End Function
Merci d'avance pour vos suggestions!
Je pense que la prise en charge de TLS 1.2 a été ajoutée dans .NET 4.5, vous avez donc besoin de l'installer, puis utilisez la classe de travail 'ServicePointManager.SecurityProtocol = DirectCast (3072, SecurityProtocolType)' pour le code 4.0. – Mark
Oui et dans ma réponse, je suis allé un peu plus loin sur la base de cette information pour terminer ma tâche. –