@@ -1104,7 +1104,7 @@ EndFunc
11041104; and the other removed from the submited form. "Checkbox" and "Button" input types are removed from the submitted form unless explicitly set. Same goes for "Radio" with exception that
11051105; only one such control can be set, the rest are removed. These controls are set by their values. Wrong value makes them invalid and therefore not part of the submited data.
11061106; +All other non-set fields are left default.
1107- ; +Last (superfluous) [[$sAdditionalData]] argument can be used to pass authorization credentials in form [["[CRED:username,password]"]] and/or HTTP request header data to add.
1107+ ; +Last (superfluous) [[$sAdditionalData]] argument can be used to pass authorization credentials in form [["[CRED:username,password]"]], magic string to ignore cerificate errors in form [["[IGNORE_CERT_ERRORS]"]] and/or HTTP request header data to add.
11081108; +
11091109; +If this function is used to upload multiple files then there are two available ways. Default would be to submit the form following RFC2388 specification.
11101110; In that case every file is represented as multipart/mixed part embedded within the multipart/form-data.
@@ -1122,9 +1122,11 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
11221122 #forceref $sFieldId21, $sData21, $sFieldId22, $sData22, $sFieldId23, $sData23, $sFieldId24, $sData24, $sFieldId25, $sData25, $sFieldId26, $sData26, $sFieldId27, $sData27, $sFieldId28, $sData28, $sFieldId29, $sData29, $sFieldId30, $sData30
11231123 #forceref $sFieldId31, $sData31, $sFieldId32, $sData32, $sFieldId33, $sData33, $sFieldId34, $sData34, $sFieldId35, $sData35, $sFieldId36, $sData36, $sFieldId37, $sData37, $sFieldId38, $sData38, $sFieldId39, $sData39, $sFieldId40, $sData40
11241124 __WinHttpDefault($sActionPage , " " )
1125- Local $iNumArgs = @NumParams , $sAdditionalHeaders , $sCredName , $sCredPass
1125+ Local $iNumArgs = @NumParams , $sAdditionalHeaders , $sCredName , $sCredPass , $iIgnoreCertErr
11261126 If Not Mod ($iNumArgs , 2 ) Then
11271127 $sAdditionalHeaders = Eval (" sFieldId" & $iNumArgs / 2 - 1 )
1128+ $iIgnoreCertErr = StringInStr ($sAdditionalHeaders , " [IGNORE_CERT_ERRORS]" )
1129+ If $iIgnoreCertErr Then $sAdditionalHeaders = StringReplace ($sAdditionalHeaders , " [IGNORE_CERT_ERRORS]" , " " , 1 )
11281130 Local $aCred = StringRegExp ($sAdditionalHeaders , " \[CRED:(.*?)\]" , 2 )
11291131 If Not @error Then
11301132 Local $aStrSplit = StringSplit ($aCred [1 ], " ," , 3 )
@@ -1146,14 +1148,14 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
11461148 $iScheme = _WinHttpQueryOption($hInternet , $WINHTTP_OPTION_CONTEXT_VALUE ); read internet scheme from the connection handle
11471149 Local $sAccpt = " Accept: text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5"
11481150 If $iScheme = $INTERNET_SCHEME_HTTPS Then
1149- $sHTML = _WinHttpSimpleSSLRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass )
1151+ $sHTML = _WinHttpSimpleSSLRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass , $iIgnoreCertErr )
11501152 ElseIf $iScheme = $INTERNET_SCHEME_HTTP Then
11511153 $sHTML = _WinHttpSimpleRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass )
11521154 Else
11531155 ; Try both http and https scheme and deduct the right one besed on response
11541156 $sHTML = _WinHttpSimpleRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass )
11551157 If @error Or @extended > = $HTTP_STATUS_BAD_REQUEST Then
1156- $sHTML = _WinHttpSimpleSSLRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass )
1158+ $sHTML = _WinHttpSimpleSSLRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass , $iIgnoreCertErr )
11571159 $iScheme = $INTERNET_SCHEME_HTTPS
11581160 Else
11591161 $iScheme = $INTERNET_SCHEME_HTTP
@@ -1540,12 +1542,12 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
15401542 EndIf
15411543 Local $hRequest
15421544 If $iScheme = $INTERNET_SCHEME_HTTPS Then
1543- $hRequest = __WinHttpFormSend($hInternet , $sMethod , $sAction , $fMultiPart , $sBoundary , $sAddData , True , $sAdditionalHeaders , $sCredName , $sCredPass )
1545+ $hRequest = __WinHttpFormSend($hInternet , $sMethod , $sAction , $fMultiPart , $sBoundary , $sAddData , True , $sAdditionalHeaders , $sCredName , $sCredPass , $iIgnoreCertErr )
15441546 Else
15451547 $hRequest = __WinHttpFormSend($hInternet , $sMethod , $sAction , $fMultiPart , $sBoundary , $sAddData , False , $sAdditionalHeaders , $sCredName , $sCredPass )
15461548 If _WinHttpQueryHeaders($hRequest , $WINHTTP_QUERY_STATUS_CODE ) > = $HTTP_STATUS_BAD_REQUEST Then
15471549 _WinHttpCloseHandle($hRequest )
1548- $hRequest = __WinHttpFormSend($hInternet , $sMethod , $sAction , $fMultiPart , $sBoundary , $sAddData , True , $sAdditionalHeaders , $sCredName , $sCredPass ) ; try adding $WINHTTP_FLAG_SECURE
1550+ $hRequest = __WinHttpFormSend($hInternet , $sMethod , $sAction , $fMultiPart , $sBoundary , $sAddData , True , $sAdditionalHeaders , $sCredName , $sCredPass , $iIgnoreCertErr ) ; try adding $WINHTTP_FLAG_SECURE
15491551 EndIf
15501552 EndIf
15511553 Local $sReturned = _WinHttpSimpleReadData($hRequest )
@@ -1735,7 +1737,7 @@ EndFunc
17351737; Author ........: ProgAndy
17361738; Related .......: _WinHttpSimpleSSLRequest, _WinHttpSimpleSendRequest, _WinHttpSimpleReadData
17371739; ===============================================================================================================================
1738- Func _WinHttpSimpleSendSSLRequest($hConnect , $sType = Default , $sPath = Default , $sReferrer = Default , $sData = Default , $sHeader = Default )
1740+ Func _WinHttpSimpleSendSSLRequest($hConnect , $sType = Default , $sPath = Default , $sReferrer = Default , $sData = Default , $sHeader = Default , $iIgnoreAllCertErrors = 0 )
17391741 ; Author: ProgAndy
17401742 __WinHttpDefault($sType , " GET" )
17411743 __WinHttpDefault($sPath , " " )
@@ -1744,6 +1746,7 @@ Func _WinHttpSimpleSendSSLRequest($hConnect, $sType = Default, $sPath = Default,
17441746 __WinHttpDefault($sHeader , $WINHTTP_NO_ADDITIONAL_HEADERS )
17451747 Local $hRequest = _WinHttpOpenRequest($hConnect , $sType , $sPath , Default , $sReferrer , Default , BitOR ($WINHTTP_FLAG_SECURE , $WINHTTP_FLAG_ESCAPE_DISABLE ))
17461748 If Not $hRequest Then Return SetError (1 , @error , 0 )
1749+ If $iIgnoreAllCertErrors Then _WinHttpSetOption($hRequest , $WINHTTP_OPTION_SECURITY_FLAGS , BitOR ($SECURITY_FLAG_IGNORE_UNKNOWN_CA , $SECURITY_FLAG_IGNORE_CERT_DATE_INVALID , $SECURITY_FLAG_IGNORE_CERT_CN_INVALID , $SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE ))
17471750 If $sType = " POST" And $sHeader = $WINHTTP_NO_ADDITIONAL_HEADERS Then $sHeader = " Content-Type: application/x-www-form-urlencoded" & @CRLF
17481751 _WinHttpSetOption($hRequest , $WINHTTP_OPTION_DECOMPRESSION , $WINHTTP_DECOMPRESSION_FLAG_ALL )
17491752 _WinHttpSetOption($hRequest , $WINHTTP_OPTION_UNSAFE_HEADER_PARSING , 1 )
@@ -1782,7 +1785,7 @@ EndFunc
17821785; Modified.......: trancexx
17831786; Related .......: _WinHttpSimpleRequest, _WinHttpSimpleSendSSLRequest, _WinHttpSimpleSendRequest, _WinHttpQueryHeaders, _WinHttpSimpleReadData
17841787; ===============================================================================================================================
1785- Func _WinHttpSimpleSSLRequest($hConnect , $sType = Default , $sPath = Default , $sReferrer = Default , $sData = Default , $sHeader = Default , $fGetHeaders = Default , $iMode = Default , $sCredName = Default , $sCredPass = Default )
1788+ Func _WinHttpSimpleSSLRequest($hConnect , $sType = Default , $sPath = Default , $sReferrer = Default , $sData = Default , $sHeader = Default , $fGetHeaders = Default , $iMode = Default , $sCredName = Default , $sCredPass = Default , $iIgnoreCertErrors = 0 )
17861789 ; Author: ProgAndy
17871790 __WinHttpDefault($sType , " GET" )
17881791 __WinHttpDefault($sPath , " " )
@@ -1794,7 +1797,7 @@ Func _WinHttpSimpleSSLRequest($hConnect, $sType = Default, $sPath = Default, $sR
17941797 __WinHttpDefault($sCredName , " " )
17951798 __WinHttpDefault($sCredPass , " " )
17961799 If $iMode > 2 Or $iMode < 0 Then Return SetError (4 , 0 , 0 )
1797- Local $hRequest = _WinHttpSimpleSendSSLRequest($hConnect , $sType , $sPath , $sReferrer , $sData , $sHeader )
1800+ Local $hRequest = _WinHttpSimpleSendSSLRequest($hConnect , $sType , $sPath , $sReferrer , $sData , $sHeader , $iIgnoreCertErrors )
17981801 If @error Then Return SetError (@error , 0 , 0 )
17991802 __WinHttpSetCredentials($hRequest , $sHeader , $sData , $sCredName , $sCredPass )
18001803 If $fGetHeaders Then
@@ -2057,10 +2060,11 @@ Func __WinHttpAttribVal($sIn, $sAttrib)
20572060 Return $aArray [UBound ($aArray ) - 1 ]
20582061EndFunc
20592062
2060- Func __WinHttpFormSend($hInternet , $sMethod , $sAction , $fMultiPart , $sBoundary , $sAddData , $fSecure = False , $sAdditionalHeaders = " " , $sCredName = " " , $sCredPass = " " )
2063+ Func __WinHttpFormSend($hInternet , $sMethod , $sAction , $fMultiPart , $sBoundary , $sAddData , $fSecure = False , $sAdditionalHeaders = " " , $sCredName = " " , $sCredPass = " " , $iIgnoreAllCertErrors = 0 )
20612064 Local $hRequest
20622065 If $fSecure Then
20632066 $hRequest = _WinHttpOpenRequest($hInternet , $sMethod , $sAction , Default , Default , Default , $WINHTTP_FLAG_SECURE )
2067+ If $iIgnoreAllCertErrors Then _WinHttpSetOption($hRequest , $WINHTTP_OPTION_SECURITY_FLAGS , BitOR ($SECURITY_FLAG_IGNORE_UNKNOWN_CA , $SECURITY_FLAG_IGNORE_CERT_DATE_INVALID , $SECURITY_FLAG_IGNORE_CERT_CN_INVALID , $SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE ))
20642068 Else
20652069 $hRequest = _WinHttpOpenRequest($hInternet , $sMethod , $sAction )
20662070 EndIf
0 commit comments