WinHttpRequest (An error occurred in the secure channel support)

Get help with using AutoHotkey and its commands and hotkeys
User avatar
TheDewd
Posts: 1384
Joined: 19 Dec 2013, 11:16
Location: USA

WinHttpRequest (An error occurred in the secure channel support)

19 Oct 2018, 11:31

I'm trying to use WinHttoRequest with POST but I keep receiving the error "An error occurred in the secure channel support".

Any ideas?

Code: Select all

#SingleInstance, Force
#Persistent

Data := "companyName=&address1=1600+Pennsylvania+Ave+NW&address2=&city=DC&state=WA&zip=20500"

WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("POST", "http://tools.usps.com/tools/app/ziplookup/zipByAddress")
WebRequest.SetRequestHeader("Host", "tools.usps.com")
WebRequest.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0")
WebRequest.SetRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01")
WebRequest.SetRequestHeader("Accept-Language", "en-US,en;q=0.5")
WebRequest.SetRequestHeader("Accept-Encoding", "gzip, deflate, br")
WebRequest.SetRequestHeader("Referer", "https://tools.usps.com/zip-code-lookup.htm?byaddress")
WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
WebRequest.SetRequestHeader("X-Requested-With", "XMLHttpRequest")
WebRequest.SetRequestHeader("Content-Length", StrLen(Data))
WebRequest.SetRequestHeader("DNT", "1")
WebRequest.SetRequestHeader("Connection", "keep-alive")
WebRequest.SetRequestHeader("Pragma", "no-cache")
WebRequest.SetRequestHeader("Cache-Control", "no-cache")

StrPut(Data, &Data, "", "UTF-8")

WebRequest.Send(Data)

Result := WebRequest.ResponseText

MsgBox, % Result

Code: Select all

---------------------------
New AutoHotkey Script.ahk
---------------------------
Error:  0x80072F7D - 
Source:		WinHttp.WinHttpRequest
Description:	An error occurred in the secure channel support


HelpFile:		(null)
HelpContext:	0

Specifically: Send

	Line#
	015: WebRequest.SetRequestHeader("X-Requested-With", "XMLHttpRequest")  
	016: WebRequest.SetRequestHeader("Content-Length", StrLen(Data))  
	017: WebRequest.SetRequestHeader("DNT", "1")  
	018: WebRequest.SetRequestHeader("Connection", "keep-alive")  
	019: WebRequest.SetRequestHeader("Pragma", "no-cache")  
	020: WebRequest.SetRequestHeader("Cache-Control", "no-cache")  
	022: StrPut(Data, &Data, "", "UTF-8")  
--->	024: WebRequest.Send(Data)  
	026: Result := WebRequest.ResponseText
	028: MsgBox,Result
	029: Exit
	030: Exit
	030: Exit

Continue running the script?
---------------------------
Yes   No   
---------------------------
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
tmplinshi
Posts: 1554
Joined: 01 Oct 2013, 14:57

Re: WinHttpRequest (An error occurred in the secure channel support)

19 Oct 2018, 16:28

Code: Select all

whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("POST", "https://tools.usps.com/tools/app/ziplookup/zipByAddress")
whr.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
whr.Send("companyName=&address1=1600+Pennsylvania+Ave+NW&address2=&city=DC&state=WA&zip=20500")
MsgBox % whr.ResponseText
User avatar
TheDewd
Posts: 1384
Joined: 19 Dec 2013, 11:16
Location: USA

Re: WinHttpRequest (An error occurred in the secure channel support)

22 Oct 2018, 14:35

I still receive an error. It is probably the security settings for this computer.
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 12:16

- You could try this:
oHTTP := ComObjCreate("MSXML2.XMLHTTP.6.0")
- Which is demonstrated here:
Lynda.com workaround - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=61969&p=264597#p264597
- Or try variants of the code by teadrinker in that thread.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
TheDewd
Posts: 1384
Joined: 19 Dec 2013, 11:16
Location: USA

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 12:22

jeeswg wrote:You could try this: oHTTP := ComObjCreate("MSXML2.XMLHTTP.6.0")

Code: Select all

Error:  0x80070005 - Access is denied.
Source:		msxml6.dll
Description:	Access is denied.


HelpFile:		(null)
HelpContext:	0

Specifically: Send

	Line#
	017: WebRequest.SetRequestHeader("X-Requested-With", "XMLHttpRequest")  
	018: WebRequest.SetRequestHeader("Content-Length", StrLen(Data))  
	019: WebRequest.SetRequestHeader("DNT", "1")  
	020: WebRequest.SetRequestHeader("Connection", "keep-alive")  
	021: WebRequest.SetRequestHeader("Pragma", "no-cache")  
	022: WebRequest.SetRequestHeader("Cache-Control", "no-cache")  
	024: StrPut(Data, &Data, "", "UTF-8")  
--->	026: WebRequest.Send(Data)  
	028: Result := WebRequest.ResponseText
	030: MsgBox,Result
	031: Exit
	032: Exit
	032: Exit
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
tank
Posts: 2815
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 14:00

What OS / Browser are you using
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:
User avatar
TheDewd
Posts: 1384
Joined: 19 Dec 2013, 11:16
Location: USA

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 14:16

tank wrote:What OS / Browser are you using
Windows 7 Enterprise Service Pack 1 64-bit

Internet Explorer 11.0.9600.19236
Update Versions: 11.0.105 (KB4480965)
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
tank
Posts: 2815
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 14:42

Sounds like a registry issue but i couldnt point to which key causes it
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 15:20

Some registry keys are mentioned here:
iis - An error occurred in the secure channel support - Classic ASP HTTP Request - Stack Overflow
https://stackoverflow.com/questions/21354992/an-error-occurred-in-the-secure-channel-support-classic-asp-http-request
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
TheDewd
Posts: 1384
Joined: 19 Dec 2013, 11:16
Location: USA

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 16:00

@teadrinker,

Thanks! Unfortunately, I'm using a laptop provided by my workplace, and installing that application requires Administrator privileges that I don't have.

I'm due for a new laptop soon, so hopefully that issue will already be patches on the new machine.
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
labrint
Posts: 132
Joined: 14 Jun 2017, 05:06

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 16:13

Is a solution involving code possible? It is not always possible to fix registries of many client pcs.
teadrinker
Posts: 1130
Joined: 29 Mar 2015, 09:41
Contact:

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 16:32

As I understand, the code must be like this:

Code: Select all

RunAsAdmin(true)
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp, DefaultSecureProtocols, 2560
if A_Is64bitOS
   RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp, DefaultSecureProtocols, 2560

RunAsAdmin(exitIfNotAdmin)  {
   commandLine := DllCall("GetCommandLine", "str")
   isRestarted := !!RegExMatch(commandLine, " /restart(?!\S)")
   
   while !( A_IsAdmin || isRestarted )  {
      try  {
         if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
         else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
      }
      catch
         break 
      ExitApp
   }
   
   if !A_IsAdmin  {
      MsgBox, Failed to run the script as admin!
      if exitIfNotAdmin
         ExitApp
   }
}
Last edited by teadrinker on 21 Feb 2019, 16:37, edited 1 time in total.
User avatar
jeeswg
Posts: 6904
Joined: 19 Dec 2016, 01:58
Location: UK

Re: WinHttpRequest (An error occurred in the secure channel support)

21 Feb 2019, 17:00

- I think the logic would be something like this (if 2 separate writes for 64-bit/32-bit are required):
- Note: I use exactly the same key name both times (I don't use Wow6432Node).

Code: Select all

SetRegView, 64
if A_Is64bitOS
	RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp, DefaultSecureProtocols, 2560
SetRegView, 32
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp, DefaultSecureProtocols, 2560
- [EDIT:] I think that teadrinker's code would be fine also, assuming that the user hasn't used SetRegView at an earlier point.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
labrint
Posts: 132
Joined: 14 Jun 2017, 05:06

Re: WinHttpRequest (An error occurred in the secure channel support)

26 Feb 2019, 03:01

jeeswg wrote:
21 Feb 2019, 12:16
- You could try this:
oHTTP := ComObjCreate("MSXML2.XMLHTTP.6.0")
- Which is demonstrated here:
Lynda.com workaround - Page 2 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=61969&p=264597#p264597
- Or try variants of the code by teadrinker in that thread.
This worked for me and all my clients Jeeswg.

Return to “Ask For Help”

Who is online

Users browsing this forum: au6, BushMange, CEA6597, howardb1, MannyKSoSo, VACO BenQ, w0z and 193 guests