CURL request in classic ASP

二次信任 提交于 2020-08-22 06:39:30

问题


Can someone help me to create classic asp code from the CURL request below?

curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/beshared-repos/"

I tried the sample code below, but it didn't work.

Dim http: Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
Dim url: url = "https://cloud.seafile.com/api2/beshared-repos/"

Dim data: data = "token=f2210dacd9c6ccb8133606d94ff8e61d99b477fd"

With http
  Call .Open("GET", url, False)
  Call .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
  Call .SetRequestHeader("Authorization", "Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd")
  Call .Send()
End With

If Left(http.Status, 1) = 2 Then
  'Request succeeded with a HTTP 2xx response, do something...
Else
  'Output error
  Call Response.Write("Server returned: " & http.Status & " " & http.StatusText)
End If

And it throws the below error message at line Call.Send()

WinHttp.WinHttpRequest error '80090326'

The message received was unexpected or badly formatted.


回答1:


The issue is not the code, I've just tested your curl call with version 7.56.0 and here are the results;

First I tried the command in your question, which failed;

>curl -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/beshared-repos/"  

curl: (6) Could not resolve host: Token
curl: (6) Could not resolve host: f2210dacd9c6ccb8133606d94ff8e61d99b477fd'
curl: (35) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.

I guessed it didn't like the single quotes used for the HTTP Authorization header so replaced them and got this;

>curl -H "Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd" "https://cloud.seafile.com/api2/beshared-repos/"  

curl: (35) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.

The problem here is the error:

schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.

which will happen regardless of what method you use to call the API.

Checking the address

https://cloud.seafile.com/api2/beshared-repos/

in a browser leads to a warning that the site is not secure in Google Chrome and using an SSL checker it appears the names do not match on the SSL certificate.

None of the common names in the certificate match the name that was entered (cloud.seafile.com). You may receive an error when accessing this site in a web browser. Learn more about name mismatch errors.



来源:https://stackoverflow.com/questions/46856852/curl-request-in-classic-asp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!