应用程序未建立TLS1.2连接
这似乎是我发布问题的几个问题的延续。我有一个应用程序,可以在发布刷新令牌时为用户令牌查询eBay API。我在vb.net中创建了一个测试应用程序,在其中将用户刷新令牌提供给表单,然后测试应用程序运行一个vb.net例程,该例程引用了RESTSHARP。当表单在测试应用程序中打开以及类在最终应用中进行启动时,创建客户端。这是在我拥有用户令牌后,将客户端重用剩余的呼叫。下面的代码。
Dim client As RestClient = New RestClient(sBaseURL)
Async Sub cmdGetCode_Click(sender As Object, e As EventArgs) Handles cmdGetCode.Click
Dim Base64Auth As String = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ClientID & ":" & ClientSec))
Dim request As RestRequest = New RestRequest(sTokURL, Method.Post)
With request
.AddHeader("Content-Type", "application/x-www-form-urlencoded")
.AddHeader("Authorization", "Basic " & Base64Auth)
.AddParameter("grant_type", "refresh_token")
.AddParameter("refresh_token", txtRefreshToken.Text)
.AddParameter("Scope", "https://api.ebay.com/oauth/api_scope/sell.inventory")
End With
Try
Dim response = Await client.PostAsync(request)
'Dim responce = Await client.ExecuteAsync(request)
If response.StatusCode = HttpStatusCode.OK Then
Dim sR As String = response.Content
'uT = JsonSerializer.Deserialize(Of userToken)(sR)
uT = New userToken
JsonConvert.PopulateObject(sR, uT)
txtAuthToken.Text = uT.access_token.ToString
txtDuration.Text = uT.expires_in.ToString
Else
txtRefreshToken.Text = "Failed to GetType tokens"
End If
Catch ex As Exception
txtRefreshToken.Text = "Failed to GetType tokens"
End Try
End Sub
这有效。我使用Fiddler进行监视,并与Api.ebay.com连接,并建立了一条隧道以进行通信。
我在最终应用程序中使用了相同的例程,但是在使用Fiddler进行监视时,它不会建立通信隧道。我从提琴手连接会话属性中看到的唯一区别是,失败似乎没有使用TLS 1.2。成功的通话有标志,
== FLAGS ==================
BitFlags: [ResponseGeneratedByFiddler, IsDecryptingTunnel] 0x2100
HTTPS-CLIENT-SESSIONID: empty
HTTPS-CLIENT-SNIHOSTNAME: api.ebay.com
HTTPS-CLIENT-VERSION: Tls12
HTTPS-SERVER-CIPHER: Aes128 128bits
HTTPS-SERVER-VERSION: Tls12
X-CLIENTIP: 127.0.0.1
X-CLIENTPORT: 50237
X-EGRESSPORT: 50238
X-HOSTIP: 209.140.129.40
X-PROCESSINFO: testrestsharp:21184
X-RESPONSEBODYTRANSFERLENGTH: 0
呼叫返回标志不成功
== FLAGS ==================
BitFlags: [ResponseGeneratedByFiddler] 0x100
X-CLIENTIP: 127.0.0.1
X-CLIENTPORT: 50298
X-EGRESSPORT: 50302
X-HOSTIP: 209.140.129.40
X-PROCESSINFO: getpolicies:24828
X-RESPONSEBODYTRANSFERLENGTH: 0
我亏本的 。这两个应用程序都使用相同的eBay URL和相同的输入变量。对正在发生的事情的任何想法将不胜感激。这两个应用程序都在同一台计算机上运行。
This seems to be a continuation of several issues I have posted questions about. I have an application that queries an eBay api for a user token when posting a refresh token. I created a test application in VB.Net where I supply the user refresh token to a form, the test app then runs a VB.NET routine which references RestSharp. The Client is created when the form opens in the test app and when the class is instanciated in the final app. This is to reuse the client for the remaining calls once I have a user token. Code below.
Dim client As RestClient = New RestClient(sBaseURL)
Async Sub cmdGetCode_Click(sender As Object, e As EventArgs) Handles cmdGetCode.Click
Dim Base64Auth As String = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(ClientID & ":" & ClientSec))
Dim request As RestRequest = New RestRequest(sTokURL, Method.Post)
With request
.AddHeader("Content-Type", "application/x-www-form-urlencoded")
.AddHeader("Authorization", "Basic " & Base64Auth)
.AddParameter("grant_type", "refresh_token")
.AddParameter("refresh_token", txtRefreshToken.Text)
.AddParameter("Scope", "https://api.ebay.com/oauth/api_scope/sell.inventory")
End With
Try
Dim response = Await client.PostAsync(request)
'Dim responce = Await client.ExecuteAsync(request)
If response.StatusCode = HttpStatusCode.OK Then
Dim sR As String = response.Content
'uT = JsonSerializer.Deserialize(Of userToken)(sR)
uT = New userToken
JsonConvert.PopulateObject(sR, uT)
txtAuthToken.Text = uT.access_token.ToString
txtDuration.Text = uT.expires_in.ToString
Else
txtRefreshToken.Text = "Failed to GetType tokens"
End If
Catch ex As Exception
txtRefreshToken.Text = "Failed to GetType tokens"
End Try
End Sub
This works. I monitor with Fiddler and it connects with api.ebay.com and establishes a tunnel to communicate over.
I use the same routine in the final application but it does not establish the communication tunnel when monitored using Fiddler. The only difference I can see from the Fiddler connection session properties is the failing one does not appear to be using TLS 1.2. The successful call has FLAGS
== FLAGS ==================
BitFlags: [ResponseGeneratedByFiddler, IsDecryptingTunnel] 0x2100
HTTPS-CLIENT-SESSIONID: empty
HTTPS-CLIENT-SNIHOSTNAME: api.ebay.com
HTTPS-CLIENT-VERSION: Tls12
HTTPS-SERVER-CIPHER: Aes128 128bits
HTTPS-SERVER-VERSION: Tls12
X-CLIENTIP: 127.0.0.1
X-CLIENTPORT: 50237
X-EGRESSPORT: 50238
X-HOSTIP: 209.140.129.40
X-PROCESSINFO: testrestsharp:21184
X-RESPONSEBODYTRANSFERLENGTH: 0
The unsuccessful call returns flags
== FLAGS ==================
BitFlags: [ResponseGeneratedByFiddler] 0x100
X-CLIENTIP: 127.0.0.1
X-CLIENTPORT: 50298
X-EGRESSPORT: 50302
X-HOSTIP: 209.140.129.40
X-PROCESSINFO: getpolicies:24828
X-RESPONSEBODYTRANSFERLENGTH: 0
I am at a loss. Both applications are using the same eBay url and the same input variables. Any thoughts on what is going on would be appreciated. Both of these applications are being run on the same computer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论