winhttp

WinHttp: How to use a temporary certificate store?

我怕爱的太早我们不能终老 提交于 2019-12-05 21:28:46
I have a C++ application that makes a HTTPS connection to one of our servers. In my ideal world, I would like the following to occur: App Starts App makes Windows trust the server's root CA (no GUI please, just system calls) App talks to server, does its work, etc. App makes windows forget about the server's root CA done I do NOT want this root CA to necessarily be trusted by other apps. Therefore I don't want to install the cert system-wide. I also would like it if the user did not need Admin privileges. My initial plan was to create an in-memory (CERT_STORE_PROV_MEMORY) store, add my cert to

How to use “WinHttp.WinHttpRequest.5.1” asynchronously?

吃可爱长大的小学妹 提交于 2019-12-05 14:02:42
The code: var WinHttpReq: OleVariant; procedure TForm1.Button1Click(Sender: TObject); begin WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1'); WinHttpReq.Open('GET', 'http://stackoverflow.com', TRUE); // asynchronously WinHttpReq.setRequestHeader('User-Agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0'); WinHttpReq.Send(); // HOW to set a callback procedure here and get the response? end; Note: I do not want to import mshttp.dll and use TLB. I want to use it via late binding. I also would like to handle exceptions if any. EDIT: I'm accepting TLama's answer becouse it gives

What is causing intermittent SEC_E_BUFFER_TOO_SMALL error coming from WinHttpSendRequest?

♀尐吖头ヾ 提交于 2019-12-05 10:06:48
I have a tool which executes an HTTP S POST command against the same URL with same headers, same post body, etc. for a number of iterations. What I have run into is that for some testers, every so often the WinHttpSendRequest() function fails and the subsequent call to GetLastError() returns SEC_E_BUFFER_TOO_SMALL (0x80090321) documented here: COM Error Codes (Security and Setup) . This is not a documented error code for WinHttpSendRequest() and fairly extensive Googling has not turned up anything at all for this. I have quadruple checked that the inputs I am providing WinHttpSendRequest() are

Get RSA public key from CRYPT_BIT_BLOB in WinHTTP?

感情迁移 提交于 2019-12-04 23:12:32
问题 I am trying to get the RSA public key info in WinHTTP. So far I've got the certificate info in CERT_CONTEXT structure. I can get encryption algorithm and others as follows: PCCERT_CONTEXT cert; DWORD certLen = sizeof(PCCERT_CONTEXT); WinHttpQueryOption(hRequest, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert, &certLen); The encryption algorithm is got by LPSTR pubKeyAlgo = cert->pCertInfo->SubjectPublicKeyInfo.Algorithm.pszObjId; And we might get the public key as follows: CRYPT_BIT_BLOB pubKey =

winHTTP GET request C++

主宰稳场 提交于 2019-12-04 18:21:37
I'll get right to the point. This is what a browser request looks like GET /index.html HTTP/1.1 This is what winHTTP does GET http://site.com/index.html HTTP/1.1 Is there any I can get the winHTTP request to be the same format as the regular one? I'm using VC++ 2008 if it makes any difference Your code should look like this: // Specify an HTTP server. if (hSession) hConnect = WinHttpConnect( hSession, L"www.example.com", INTERNET_DEFAULT_HTTP_PORT, 0); // Create an HTTP request handle. if (hConnect) hRequest = WinHttpOpenRequest( hConnect, L"GET", L"/path/resource.html", NULL, WINHTTP_NO

HttpAddUrl on localhost fails for non-admin users

一曲冷凌霜 提交于 2019-12-04 18:06:33
Using the Windows HTTP API I'm running a HTTP file server on localhost. This involves calling HttpAddUrl(hRequestQueue, L"http://localhost:80/", NULL) . This fails with ERROR_ACCESS_DENIED unless the user runs the application as administrator. I need this functionality for users who don't have admin privileges. (What's wrong with a user running a localhost server anyway? It's just for the user themselves.) I found a hotfix for Vista and XP which seems aimed at solving this, but there's nothing for Windows 7. The article implies it was fixed in Vista SP1, and I have Windows 7 SP1 and it's still

WinHttp used in async mode - ERROR_INTERNET_CANNOT_CONNECT how to cleanly close connection

∥☆過路亽.° 提交于 2019-12-04 16:01:44
I get lots of ERROR_INTERNET_CANNOT_CONNECT (12029 code) in callback procedure of the request. I use WinHttp in async mode(on a server). How do you cleanly close the connection in this case. Do you just use something like this(like you normally close a connection?): ::WinHttpSetStatusCallback(handle, NULL, 0, 0); ::WinHttpCloseHandle(this->handle)); I ask this because I have some strange memory leaking associated with winhttp dll that occurs in the situation described(want to create hundreds of concurrent connections that are probably blocked by the firm internal firewall or destination server

What is phrase “URL reservation in HTTP.SYS” means?

旧巷老猫 提交于 2019-12-04 12:11:53
Can't understand the meaning of this phrase. People on forums suggests each other to reserve url in HTTP.sys, but what does it mean? What is it for? How does it works? All it comes from HttpWebRequest uac problems. Several Win32 APIs and .NET framework components (such as WCF) utilize the HTTP Server API when they want to send or receive HTTP requests targeted at the local machine. The HTTP Server API basically provides such functionality in a manner managed by the OS without the need for deploying a standalone web server such as IIS on the machine. At this point it's probably best to quote

What's the correct way to use win32inet.WinHttpGetProxyForUrl

浪尽此生 提交于 2019-12-04 11:46:07
I'm trying to use a feature of the Microsoft WinHttp library that has been exposed by the developers of Win32com. Unfortunately most of the library does not seem to be documented and there are no example of the correct way to use the win32inet features via the win32com library. This is what I have so far: import win32inet hinternet = win32inet.InternetOpen("foo 1.0", 0, "", "", 0) # Does not work!!! proxy = win32inet.WinHttpGetProxyForUrl( hinternet, u"http://www.foo.com", 0 ) As you can see, all I am trying to do is use the win32inet feature to find out which proxy is the appropriate one to

WinHttp TLS connection in classic asp

℡╲_俬逩灬. 提交于 2019-12-04 05:49:07
问题 I'm trying to send payment data to SagePay and, as they are turning off SSL, it needs to be sent using TLS. The code I have is as follows: set httpRequest = Server.CreateObject("WinHttp.WinHttprequest.5.1") httpRequest.Open "POST", CStr(strPurchaseURL), false httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" httpRequest.send strPost strResponse = httpRequest.responseText I've been told that adding an option lets you set the protocol used but the only one I've