Jump to content
Code4Fun

WinHTTP - could not send request

Recommended Posts

Hello, here's my problem. I wrote a script which uses WinHTTP.au3 to search a certain SSL protected website and if it found something it sends me a message via push up on the smartphone. I developed the whole thing on the company notebook in a VPN environment (Microsoft Direct Access). I then wanted to run the compiled EXE non-stop in the company network on a server, but here the EXE exits me. At home the EXE runs very stable and good with and without VPN connection. The first suspicion was on the proxy (proxy.pac), but there it is defined, that if I run in the 10.x.x.x. network, the way DIRECT goes out. I also activated the IPv6 protocol on the server, because it is also active on my Win10. With @error the _WinHttpSimpleSendSSLRequest flies away with error 2 (could not send request). Currently I am a bit helpless.

Here some code

$hSession = _WinHttpOpen('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0')
$sServerName = 'www.fqdn.tld'
$hConnect = _WinHttpConnect($hSession, $sServerName, 443)
If @error Then
    MsgBox(48, "Error", "Error getting connection handle." & @CRLF & "Error number is " & @error)
Else
    MsgBox(64, "Yes!", "Handle is get! $hConnect = " & $hConnect)
EndIf

$sPaket = _WinHttpSimpleSSLRequest($hConnect, 'GET', '/')
If @error Then
    MsgBox(48, "Error", "Failure." & @CRLF & "Error number is " & @error)
Else
    MsgBox(0, "Show $sPaket", $sPaket)
EndIf
$aCSRF = _StringBetween($sPaket, 'name="csrf" value="', '" />')
ConsoleWrite("$aCSRF ist: " & $aCSRF[0] & @CRLF)

At the first "If" i get the YES Message, at the second "If" i get Error = 2

Share this post


Link to post
Share on other sites

@Code4Fun perhaps you could explain why you're trying to obtain a CSRF token? And what is the website?

=====In case you missed it, this is a Mod stepping into a thread. Please stay out unless and until directed otherwise=====

Share this post


Link to post
Share on other sites

It seems your source name for the object is csrf, rather than trying to obtain a token (poor choice of coding on the page). So this thread is fine to continue, so long as it does not tread into territory that is against the forum rules.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...