2017-03-15 5 views
0

TLS 1.2를 지원하도록 SSL TLS 채널을 업데이트해야하는 기존 Visual Studio 2010 vb.net 응용 프로그램이 있습니다. 여러 가지 옵션을 시도했는데 (시도에 대한 주석 코드 참조) 모두 "SSL/TLS 보안 채널을 만들 수 없습니다."라는 동일한 오류로 안내합니다. 내가 뭘 놓치고 있니?SSL TLS 1.2 채널 만들기 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 

미리 제안 해 주셔서 감사합니다.

+1

TLS 1.2 지원이 .NET 4.5에 추가되었으므로 설치가 필요하고 4.0 코드에 대해 'ServicePointManager.SecurityProtocol = DirectCast (3072, SecurityProtocolType)'해결 방법을 사용해야합니다. – Mark

+0

예, 답을 통해이 작업을 완료하기 위해이 정보를 바탕으로 몇 가지 단계를 더 진행했습니다. –

답변

0

Microsoft에서 .net 4.6 Targeting Pack을 다운로드하고 설치 한 후 완전히 성공했습니다. 이로써 TLS 1.2 지원을 포함하고 .Net 4.6을 게시 옵션으로 추가 한 전체 .net 업그레이드가 추가되었습니다. 일단 업그레이드하고 게시하면 위 코드는 TLS 1.2로 설정된 보안 프로토콜로 작업했습니다.