Connecting Tech Pros Worldwide Help | Site Map

Help needed for HTTPS download

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 04:52 AM
Camel
Guest
 
Posts: n/a
Default Help needed for HTTPS download

Hello All,

I have a short program (see below ) that downloads a secure page. It worked
fine when I changed in the InternetConnect function
server name to: www.paypal.com
port to: INTERNET_DEFAULT_HTTPS_PORT
and changed in the HttpOpenRequest
object name to: index.html

However, when I changed the code to download a localhost file login.html, it
printed nonsensical code. I installed and configured Tomcat on my PC. The
server runs on port 8443. I can access Tomcat server and view login.html
through HTTPS protocol in IE. Everything seemed fine in IE.

What could be the problem with my code below?
Thank you in advance for your help.

---------------my code-----------------

#include<windows.h>
#include<wininet.h>
#include<stdio.h>

int main() {

HINTERNET Initialize,hConnect,hReq;
DWORD dwBytes;
char ch;

Initialize = InternetOpen
("httpsexample",INTERNET_OPEN_TYPE_DIRECT,NULL,NUL L,0);
hConnect = InternetConnect (
Initialize, // InternetOpen handle
"localhost", // Server name
8443, // HTTPS port
"", // User name
"", // User password
INTERNET_SERVICE_HTTP, // Service
0, // Flags
0 // Context
);

hReq = HttpOpenRequest (
hConnect, // InternetConnect handle
"GET", // Method
"", // Object name
HTTP_VERSION, // Version
"", // Referrer
NULL, // Extra headers
INTERNET_FLAG_SECURE && INTERNET_FLAG_IGNORE_CERT_CN_INVALID
&& INTERNET_FLAG_IGNORE_CERT_DATE_INVALID , // Flags
0 // Context
);


hReq = HttpOpenRequest(hConnect,NULL,"/login.html",NULL,NULL,NULL,0,0);

if(HttpSendRequest(hReq,NULL,0,NULL,0))
{
while(InternetReadFile(hReq,&ch,1,&dwBytes))
{
if(dwBytes != 1)break;
putchar(ch);
}
}

/*close file , terminate server connection and
deinitialize the wininet library*/
InternetCloseHandle(hReq);
InternetCloseHandle(hConnect);
InternetCloseHandle(Initialize);
return 0;
}









  #2  
Old July 23rd, 2005, 04:52 AM
red floyd
Guest
 
Posts: n/a
Default Re: Help needed for HTTPS download

Camel wrote:[color=blue]
> Hello All,
>
> I have a short program (see below ) that downloads a secure page. It worked
> fine when I changed in the InternetConnect function
> server name to: www.paypal.com
> port to: INTERNET_DEFAULT_HTTPS_PORT
> and changed in the HttpOpenRequest
> object name to: index.html
>
> However, when I changed the code to download a localhost file login.html, it
> printed nonsensical code. I installed and configured Tomcat on my PC. The
> server runs on port 8443. I can access Tomcat server and view login.html
> through HTTPS protocol in IE. Everything seemed fine in IE.
>
> What could be the problem with my code below?
> Thank you in advance for your help.
>
> ---------------my code-----------------
>
> [redacted][/color]

Your question relates to the HTTPS implementation on your system. There
is no C++ language question. Not to mention the fact that your code is
C, not C++.

Recommend you post to a Microsoft group:

comp.os.ms-windows.programmer or
comp.os.ms-windows.programmer.networks


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.