Login no longer working

Hi! The code below was working until today (or perhaps yesterday?). Now, it throws an error at the line

Dim responseArray As Byte() = myWebClient.UploadValues(postURL, “POST”, myNameValueCollection2)

The error is:

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

Can anyone help? Full code below:

Public Sub MemberfulLogin()   ' This is actually the Patreon login
    Dim myWebClient As New System.Net.WebClient()
    Dim myNameValueCollection As New NameValueCollection()
    Dim myNameValueCollection2 As New NameValueCollection()

    Dim postURL = "https://api.patreon.com/oauth2/token"

    Dim client_id = ConfigurationManager.AppSettings("patreon_ClientId")
    Dim client_secret = ConfigurationManager.AppSettings("patreon_ClientSecret")

    Dim grant_type = "authorization_code"
    Dim code = Request.QueryString("code")

    myNameValueCollection.Add("code", code)
    myNameValueCollection.Add("grant_type", grant_type)

    myNameValueCollection.Add("client_id", client_id)
    myNameValueCollection.Add("client_secret", client_secret)

    Dim strHost = Request.Url.Host
    Dim strProtocol As String

    If strHost = "localhost" Or strHost = "online2.seterra.com" Or strHost = "onlinebeta.seterra.com" Then strProtocol = "http" Else strProtocol = "https"

    myNameValueCollection.Add("redirect_uri", strProtocol & "://" & strHost & "/memberRedirect.aspx")

    System.Net.ServicePointManager.Expect100Continue = True
    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11

    Dim responseArray As Byte() = myWebClient.UploadValues(postURL, "POST", myNameValueCollection2)

    Dim strResp = Encoding.ASCII.GetString(responseArray)
    Dim objResp = Newtonsoft.Json.JsonConvert.DeserializeObject(Of MemResp)(strResp)

    lblMessage3.Text = objResp.access_token
    getMemberInfo(objResp.access_token, objResp.refresh_token)

End Sub

Hi Seterra!
You are using TLS 1.1, and 1.2 is the minimum we support as of Jan 2020.

In line:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11

1 Like

Thanks! Changing it to Tls12 made everything work again!