@@ -1104,7 +1104,7 @@ EndFunc
1104
1104
; 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
1105
1105
; 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.
1106
1106
; +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.
1108
1108
; +
1109
1109
; +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.
1110
1110
; 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 =
1122
1122
#forceref $sFieldId21, $sData21, $sFieldId22, $sData22, $sFieldId23, $sData23, $sFieldId24, $sData24, $sFieldId25, $sData25, $sFieldId26, $sData26, $sFieldId27, $sData27, $sFieldId28, $sData28, $sFieldId29, $sData29, $sFieldId30, $sData30
1123
1123
#forceref $sFieldId31, $sData31, $sFieldId32, $sData32, $sFieldId33, $sData33, $sFieldId34, $sData34, $sFieldId35, $sData35, $sFieldId36, $sData36, $sFieldId37, $sData37, $sFieldId38, $sData38, $sFieldId39, $sData39, $sFieldId40, $sData40
1124
1124
__WinHttpDefault($sActionPage , " " )
1125
- Local $iNumArgs = @NumParams , $sAdditionalHeaders , $sCredName , $sCredPass
1125
+ Local $iNumArgs = @NumParams , $sAdditionalHeaders , $sCredName , $sCredPass , $iIgnoreCertErr
1126
1126
If Not Mod ($iNumArgs , 2 ) Then
1127
1127
$sAdditionalHeaders = Eval (" sFieldId" & $iNumArgs / 2 - 1 )
1128
+ $iIgnoreCertErr = StringInStr ($sAdditionalHeaders , " [IGNORE_CERT_ERRORS]" )
1129
+ If $iIgnoreCertErr Then $sAdditionalHeaders = StringReplace ($sAdditionalHeaders , " [IGNORE_CERT_ERRORS]" , " " , 1 )
1128
1130
Local $aCred = StringRegExp ($sAdditionalHeaders , " \[CRED:(.*?)\]" , 2 )
1129
1131
If Not @error Then
1130
1132
Local $aStrSplit = StringSplit ($aCred [1 ], " ," , 3 )
@@ -1146,14 +1148,14 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1146
1148
$iScheme = _WinHttpQueryOption($hInternet , $WINHTTP_OPTION_CONTEXT_VALUE ); read internet scheme from the connection handle
1147
1149
Local $sAccpt = " Accept: text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5"
1148
1150
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 )
1150
1152
ElseIf $iScheme = $INTERNET_SCHEME_HTTP Then
1151
1153
$sHTML = _WinHttpSimpleRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass )
1152
1154
Else
1153
1155
; Try both http and https scheme and deduct the right one besed on response
1154
1156
$sHTML = _WinHttpSimpleRequest($hInternet , Default , $sActionPage , Default , Default , $sAccpt , Default , Default , $sCredName , $sCredPass )
1155
1157
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 )
1157
1159
$iScheme = $INTERNET_SCHEME_HTTPS
1158
1160
Else
1159
1161
$iScheme = $INTERNET_SCHEME_HTTP
@@ -1540,12 +1542,12 @@ Func _WinHttpSimpleFormFill(ByRef $hInternet, $sActionPage = Default, $sFormId =
1540
1542
EndIf
1541
1543
Local $hRequest
1542
1544
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 )
1544
1546
Else
1545
1547
$hRequest = __WinHttpFormSend($hInternet , $sMethod , $sAction , $fMultiPart , $sBoundary , $sAddData , False , $sAdditionalHeaders , $sCredName , $sCredPass )
1546
1548
If _WinHttpQueryHeaders($hRequest , $WINHTTP_QUERY_STATUS_CODE ) > = $HTTP_STATUS_BAD_REQUEST Then
1547
1549
_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
1549
1551
EndIf
1550
1552
EndIf
1551
1553
Local $sReturned = _WinHttpSimpleReadData($hRequest )
@@ -1735,7 +1737,7 @@ EndFunc
1735
1737
; Author ........: ProgAndy
1736
1738
; Related .......: _WinHttpSimpleSSLRequest, _WinHttpSimpleSendRequest, _WinHttpSimpleReadData
1737
1739
; ===============================================================================================================================
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 )
1739
1741
; Author: ProgAndy
1740
1742
__WinHttpDefault($sType , " GET" )
1741
1743
__WinHttpDefault($sPath , " " )
@@ -1744,6 +1746,7 @@ Func _WinHttpSimpleSendSSLRequest($hConnect, $sType = Default, $sPath = Default,
1744
1746
__WinHttpDefault($sHeader , $WINHTTP_NO_ADDITIONAL_HEADERS )
1745
1747
Local $hRequest = _WinHttpOpenRequest($hConnect , $sType , $sPath , Default , $sReferrer , Default , BitOR ($WINHTTP_FLAG_SECURE , $WINHTTP_FLAG_ESCAPE_DISABLE ))
1746
1748
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 ))
1747
1750
If $sType = " POST" And $sHeader = $WINHTTP_NO_ADDITIONAL_HEADERS Then $sHeader = " Content-Type: application/x-www-form-urlencoded" & @CRLF
1748
1751
_WinHttpSetOption($hRequest , $WINHTTP_OPTION_DECOMPRESSION , $WINHTTP_DECOMPRESSION_FLAG_ALL )
1749
1752
_WinHttpSetOption($hRequest , $WINHTTP_OPTION_UNSAFE_HEADER_PARSING , 1 )
@@ -1782,7 +1785,7 @@ EndFunc
1782
1785
; Modified.......: trancexx
1783
1786
; Related .......: _WinHttpSimpleRequest, _WinHttpSimpleSendSSLRequest, _WinHttpSimpleSendRequest, _WinHttpQueryHeaders, _WinHttpSimpleReadData
1784
1787
; ===============================================================================================================================
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 )
1786
1789
; Author: ProgAndy
1787
1790
__WinHttpDefault($sType , " GET" )
1788
1791
__WinHttpDefault($sPath , " " )
@@ -1794,7 +1797,7 @@ Func _WinHttpSimpleSSLRequest($hConnect, $sType = Default, $sPath = Default, $sR
1794
1797
__WinHttpDefault($sCredName , " " )
1795
1798
__WinHttpDefault($sCredPass , " " )
1796
1799
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 )
1798
1801
If @error Then Return SetError (@error , 0 , 0 )
1799
1802
__WinHttpSetCredentials($hRequest , $sHeader , $sData , $sCredName , $sCredPass )
1800
1803
If $fGetHeaders Then
@@ -2057,10 +2060,11 @@ Func __WinHttpAttribVal($sIn, $sAttrib)
2057
2060
Return $aArray [UBound ($aArray ) - 1 ]
2058
2061
EndFunc
2059
2062
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 )
2061
2064
Local $hRequest
2062
2065
If $fSecure Then
2063
2066
$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 ))
2064
2068
Else
2065
2069
$hRequest = _WinHttpOpenRequest($hInternet , $sMethod , $sAction )
2066
2070
EndIf
0 commit comments