Jump to content

Reading data from web - https on Windows 7


Recommended Posts

Hi!

I've created a program which is reading data from the web. The site is using https, and while it works fine for me on Windows 10 x64, it fails on Windows 7 x64 at my partner.

I am using ObjCreate("WinHttp.WinHttpRequest.5.1") and the Send method always fails with error: "An error occurred in the secure channel support".

I've read through that Win7 does not support TLS1.2 by default, so I tried to fix this first. I followed this article:

https://support.microsoft.com/en-us/topic/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-winhttp-in-windows-c4bd73d2-31d7-761e-0178-11268bb10392

- It turned out that kb3140245 is already installed. Checked winhttp.dll and webio.dll files in SysWOW64 and system32 folder in C:\Windows, both are correct (winhttp: 6.1.7601.24xxx, webio: 6.1.7601.23375)

- Registry keys seems to be correct. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client and TLS 1.2\Client are there, both having DisabledByDefault as 0. HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp has DefaultSecureProtocols with 0xa80, also tried with 0x800, same error

- Control Panel's internet settings checked, TLS1.0 to TLS 1.2 enabled, SSL2.0 and SSL3.0 are disabled. Tried to switch on all, enable only 1.2, same error.

- Tried to add $objHTTP.option(9) = 2048 to use TLS 1.2, same error

- Tried to change the object to ObjCreate("MSXML2.ServerXMLHTTP.6.0"), same error

- Tried to change the link to http:// instead of https:// - it has a redirect, page does not support http at all.

- Tried to use _IE to navigate to the page and get the content. As I am working with JSONs, it fails - IE shows the download button instead of rendering the JSON text, like Chrome does.

 

I am out of ideas. This is really inconvenient for me, my partner is not even able to use the software. Sure I could say Win7 is old, outdated, should be updated - that's not my choice.

Do somebody have idea how to retrieve data from the web w/o winhttp, or how to get rid of this error?

 

Thank you in advance,

Attila

Edited by AttilaP
Link to post
Share on other sites

I have got some issues using winhttp in an old OS too and it worked super nice using curl

Edit: example of use

#include <AutoItConstants.au3>

Func __INetRead($url)
   Local $cmd = "curl -L -s -k -A 'Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1)' " & $url
   Local $iPID = Run($cmd, "", @SW_HIDE, $STDOUT_CHILD)
   ProcessWaitClose($iPID)
   Local $output = StdoutRead($iPID)
   Return $output
EndFunc

 

Edited by mikell
Link to post
Share on other sites
Link to post
Share on other sites

Thank you for your suggestions!

I have to use GET and POST, so it seems curl might be able to do the job... But it does not handle the cookies like WinHTTP does. If I have to handle the cookies manually, that's really a headache...

Link to post
Share on other sites

@AttilaP

Is the COM return code 0x80072F7D (Error 12157), 0x80072F8F (Error 12175), or some other code?  The possible root causes and resolutions of the issue is dependent on the specific return code.

Edited by TheXman
Link to post
Share on other sites

Good, that one is easier to resolve.

Attached are the registry keys that are updated by the MS EasyFix app.  These keys assume that the host machine is Win7 x64.  It is a .reg file so, after confirming the values are the ones you want, you can merge them by double-clicking on the file or you can manually confirm the values of each key.  Can you see if these entries work for you?

 

 

TLS Fix x64.reg

Link to post
Share on other sites

We had similar issue and we have it fixed, do not remeber how but I think that I have solution in my office. I would be able to check at monday.

Signature beginning:
Please remember: "AutoIt".....  Wondering who uses AutoIt and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-03-17

Link to post
Share on other sites
1 hour ago, TheXman said:

Good, that one is easier to resolve.

Attached are the registry keys that are updated by the MS EasyFix app.  These keys assume that the host machine is Win7 x64.  It is a .reg file so, after confirming the values are the ones you want, you can merge them by double-clicking on the file or you can manually confirm the values of each key.  Can you see if these entries work for you?

 

 

TLS Fix x64.reg 2.03 kB · 3 downloads

Unfortunately this fix did not help, the result is the same. :(

Link to post
Share on other sites

Can you post your script or at least an example that produces the error?

Also, have you tried rerunning the standalone Windows Update?  I have also attached the original, signed, EasyFix from Microsoft just in case it did more than set the registry keys that I listed.

The EasyFix needs to be run after the Windows Update.

 

MicrosoftEasyFix51044_WinHttp Secure Protocol Registry Fix.msi

Edited by TheXman
Link to post
Share on other sites
On 2/19/2021 at 5:40 PM, mLipok said:

We had similar issue and we have it fixed, do not remeber how but I think that I have solution in my office. I would be able to check at monday.

https://docs.microsoft.com/pl-pl/dotnet/framework/network-programming/tls

Quote

Windows Registry Editor Version 5.00 

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v2.0.50727] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319] "SystemDefaultTlsVersions"=dword:00000001 "SchUseStrongCrypto"=dword:00000001

 

I was able to find some helpfull information today.
I think that there was also other... I will try to find tomorrow.

TLS_SSL_NetFramework.reg

Edited by mLipok

Signature beginning:
Please remember: "AutoIt".....  Wondering who uses AutoIt and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:How to get reference to PDF object embeded in IE *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2021-03-17

Link to post
Share on other sites

We tried all registry patches, without result.

BUT!

Nine's answer pushed me towards the solution: I tried the WinHTTP library. As I mentioned, I used ObjCreate("WinHttp.WinHttpRequest.5.1") to initiate the object, and the result was not working. While, using the WinHTTP library it works flawlessly, even without $WINHTTP_FLAG_SECURE flag (when it was set, nothing returned).

So, I've made a small function to be able to GET and POST to different webpages, which you can find here - might be useful for somebody in the future:

Global Const $USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"
Global $hOpen = _WinHttpOpen()

...

Func Call_HTTP($strBaseURL, $strURL, $strMode, $strData = '', $strContentType = '')
    Local $hConnect = _WinHttpConnect($hOpen, $strBaseURL)
    Local $hRequest = _WinHttpOpenRequest($hConnect, $strMode, $strURL)
    _WinHttpAddRequestHeaders($hRequest, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
    If $strContentType <> '' Then _WinHttpAddRequestHeaders($hRequest, "Content-Type: " & $strContentType)
    _WinHttpAddRequestHeaders($hRequest, "User-Agent: " & $USERAGENT)
    
    _WinHttpSendRequest($hRequest, Default, $strMode = 'POST' ? $strData : '')
    _WinHttpReceiveResponse($hRequest)
    Local $sReturned = ''
    If _WinHttpQueryDataAvailable($hRequest) Then
        Do
            $sReturned &= _WinHttpReadData($hRequest)
        Until @error
    EndIf
    Return $sReturned
EndFunc   ;==>Call_HTTP

Parameters:

$strBaseURL is the base URL, like "http://google.com"
$strURL is the rest of the URL (if any), like "/?q=test"
$strMode is either GET or POST
$strData is the data to be sent when it is a POST request
$strContentType is the Content-Type header

I know that CrackURL could have been used to split up the URL, but my old function was created like this already.

Thank you everybody, really, REALLY appreciated.

Edited by AttilaP
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...