Dreamfire Posted June 21, 2010 Posted June 21, 2010 (edited) Hi guys,I'm breaking my head over this and could use some assistance. #include 'WinINet.au3' _WinINet_Startup() $iWN_OPEN = _WinINet_InternetOpen('AutoIT', $INTERNET_OPEN_TYPE_PRECONFIG) ;=== $INTERNET_OPEN_TYPE_PRECONFIG required for proxy settings $iWN_CONNECT = _WinINet_InternetConnect($iWN_OPEN, $INTERNET_SERVICE_HTTP, 'HOSTNAME_GOES_HERE_BUT_ITS_NOT_ACCESSABLE_FROM_OUTSIDE_THE_WORKPLACE', $INTERNET_DEFAULT_HTTPS_PORT) ;=== $INTERNET_DEFAULT_HTTPS_PORT for secure (port 443) $iWN_OPEN_REQUEST = _WinINet_HttpOpenRequest($iWN_CONNECT, 'POST', '', $INTERNET_FLAG_SECURE) ;=== $INTERNET_FLAG_SECURE for https option ;== $iWN_ADD_HEADER = _WinINet_HttpAddRequestHeaders($iWN_OPEN_REQUEST, 'Authorization: Basic THIS_YOU_DONT_NEED_TO_KNOW_EITHER' & @CRLF, BitOR($HTTP_ADDREQ_FLAG_REPLACE,$HTTP_ADDREQ_FLAG_ADD)) $iWN_ADD_HEADER = _WinINet_HttpAddRequestHeaders($iWN_OPEN_REQUEST, 'Content-Length: 4' & @CRLF, BitOR($HTTP_ADDREQ_FLAG_REPLACE,$HTTP_ADDREQ_FLAG_ADD)) $iWN_ADD_HEADER = _WinINet_HttpAddRequestHeaders($iWN_OPEN_REQUEST, 'Content-Type: application/x-www-form-urlencoded' & @CRLF, BitOR($HTTP_ADDREQ_FLAG_REPLACE,$HTTP_ADDREQ_FLAG_ADD)) $iWN_ADD_HEADER = _WinINet_HttpAddRequestHeaders($iWN_OPEN_REQUEST, 'Accept: */*' & @CRLF, BitOR($HTTP_ADDREQ_FLAG_REPLACE,$HTTP_ADDREQ_FLAG_ADD)) $iWN_ADD_HEADER = _WinINet_HttpAddRequestHeaders($iWN_OPEN_REQUEST, 'Connection: Keep-Alive' & @CRLF, BitOR($HTTP_ADDREQ_FLAG_REPLACE,$HTTP_ADDREQ_FLAG_ADD)) ;== ; #1 HELP NEEDED HERE ; THIS IS WHAT I CANT GET TO WORK / I DONT UNDERSTAND THE DLLSTRUCT SYSTEM ECT ; I WANT TO ADD >>> $SECURITY_FLAG_IGNORE_UNKNOWN_CA <<< TO THE HANDLE, SO IT WIL IGNORE THE CERTIFICATE ERROR AND COMPLETE THE REQUEST $iOPTION = _WinINet_InternetSetOption($iWN_OPEN_REQUEST, $SECURITY_FLAG_IGNORE_UNKNOWN_CA, ???) ;== ; THIS IS WHERE IT GOES WRONG (AND I KNOW WHY > ERROR_INTERNET_INVALID_CA (SEE #1) $iWN_SEND_REQUEST = _WinINet_HttpSendRequest($iWN_OPEN_REQUEST, Default, StringToBinary('test')) ;== $iDATA_AVAILABLE = _WinINet_InternetQueryDataAvailable($iWN_OPEN_REQUEST) _WinINet_InternetCloseHandle($iWN_OPEN_REQUEST) _WinINet_InternetCloseHandle($iWN_CONNECT) _WinINet_InternetCloseHandle($iWN_OPEN) _WinINet_Shutdown()Information about solution method here, only i can't figure out how to make that work in AutoIt > http://support.microsoft.com/kb/182888 Edited June 21, 2010 by Dreamfire
MiserableLife Posted June 22, 2010 Posted June 22, 2010 (edited) maybe these help?WinINet.au3InternetSetOption Function_WinINet_InternetSetOption($hInternet, $iOption, $vBuffer)I think $vbuffer is $iOption(or the same length)Maybe $iOption = $INTERNET_OPTION_SECURITY_FLAGS$vBuffer = $SECURITY_FLAG_IGNORE_UNKNOWN_CASee :Option Flagsexpandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinINet_InternetSetOption ; Description ...: Sets an Internet option. ; Syntax ........: _WinINet_InternetSetOption($hInternet, $iOption, $vBuffer) ; Parameters ....: $hInternet - Handle on which to set information. ; $iOption - Internet option to be set. Can be one of the $INTERNET_OPTION_* options. ; $vBuffer - The option setting. ; Return values .: Success - True ; Failure - False, sets @error to 1 ; Author ........: Ultima ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: @@MsdnLink@@ InternetSetOption ; Example .......: ; =============================================================================================================================== Func _WinINet_InternetSetOption($hInternet, $iOption, $vBuffer) ; Set data/structures up Local $tBuffer, $iBuffer If IsBinary($vBuffer) Then $iBuffer = BinaryLen($vBuffer) $tBuffer = DllStructCreate("byte[" & $iBuffer & "]") Else $tBuffer = DllStructCreate($WIN32_TCHAR & "[" & (StringLen($vBuffer)+1) & "]") $iBuffer = DllStructGetSize($tBuffer) EndIf DllStructSetData($tBuffer, 1, $vBuffer) ; Make DLL call Local $avResult = DllCall($__WinINet_hDLL, _ "int", "InternetSetOption" & $WIN32_FTYPE, _ "ptr", $hInternet, _ "dword", $iOption, _ "ptr", DllStructGetPtr($tBuffer), _ "dword", $iBuffer _ ) ; Return response If @error Or Not $avResult[0] Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinINet_InternetSetOptionYou can try a tool called WireShark to check your out going package from AutoIt Edited June 22, 2010 by MiserableLife
Dreamfire Posted June 22, 2010 Author Posted June 22, 2010 (edited) I did try this also, but its more complicated than that. $iOPTION_SET = _WinINet_InternetSetOption($iWN_OPEN_REQUEST, $INTERNET_OPTION_SECURITY_FLAGS, $SECURITY_FLAG_IGNORE_REVOCATION) This returns true so that should mean that it set the option. but when i try to check this by calling the following before and after i set the option $iQUERY_OPTION = _WinINet_InternetQueryOption($iWN_OPEN_REQUEST, $INTERNET_OPTION_SECURITY_FLAGS) In both cases i get a huge binary return that stays the same (0x00000000000000000000000000000000000000000000000000000000000000000000000000000+a few more hundred zeros) So it looks likes it did not set the option, but i think i can not be sure of that. You can try a tool called WireShark to check your out going package from AutoIt I use Fiddler, but if you can tell me how to check that with Wireshark i'l try it out. Edited June 22, 2010 by Dreamfire
Dreamfire Posted July 15, 2010 Author Posted July 15, 2010 Are all the experts on vacation Still need a solution for this!
Dreamfire Posted September 7, 2010 Author Posted September 7, 2010 (edited) http://www.autoitscript.com/forum/index.php?showtopic=111769I looked again at WinHTTP and found an error in _WinHTTPSetOption. It was only designed for String-options.So by using _WinINet_InternetSetOptionEx() it worked.SOLVED - THREAD MAY BE LOCKED Edited September 7, 2010 by Dreamfire
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now