PowerBASIC Forums
  Programming the Internet
  SSL/HTTPS

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   SSL/HTTPS
Ron Pierce
Member
posted February 05, 2002 05:00 AM     Click Here to See the Profile for Ron Pierce     Edit/Delete Message   Reply w/Quote
Is anyone aware of a means of accessing a HTTPS web page with PowerBASIC? In VB, the Internet Transfer Control supports this.
Any help hitting a HTTPS page with PBCC/PBDLL greatly appreciated.

Does anyone use SSL with PowerBASIC? I can't find any references.

Thanks,

Ron

IP: Logged

Jakob Faarvang
Member
posted February 05, 2002 08:45 AM     Click Here to See the Profile for Jakob Faarvang     Edit/Delete Message   Reply w/Quote
Just use the WinInet functions to do this.

An example is available here http://www.powerbasic.com/support/forums/Forum7/HTML/001135.html

To fetch an https page, just send the URL of the page through Wininet, e.g. https://secureserver/

If your page is password protected, just use a URL similar to the following:

https://username:password@secureserver/address/

Good luck,
- Jakob

[This message has been edited by Jakob Faarvang (edited February 05, 2002).]

IP: Logged

Ron Pierce
Member
posted February 06, 2002 05:20 AM     Click Here to See the Profile for Ron Pierce     Edit/Delete Message   Reply w/Quote
Thanks, Jakob. I will give this a go. Have you used the code to "talk" to a HTTPS url?

IP: Logged

Jakob Faarvang
Member
posted February 07, 2002 01:44 AM     Click Here to See the Profile for Jakob Faarvang     Edit/Delete Message   Reply w/Quote
Yep. It's very straightforward - WinInet doesn't really care if you talk to HTTP or HTTPS servers (or gopher, ftp etc. servers, for that matter).

(Note that for FTP servers, there are a whole different set of commands, but you can still use the mentioned code to fetch a direct file - e.g. ftp://ftp.mysite.com/address/filename.txt )

- Jakob

IP: Logged

Joshua Zavelovich
Member
posted November 05, 2002 10:22 AM     Click Here to See the Profile for Joshua Zavelovich     Edit/Delete Message   Reply w/Quote
Hi Jakob:

I tested your code - works fine! Unfortunately I cannot use the same approach in my task. The WININET function that you used in this sample InternetOpenUrl - always create "GET" header in the message sent to the server. I need to "POST" the message and I tried to accomplish it with the sequence of other WININET functions that should be equivalent to InternetOpenUrl:

InternetConnect
HttpOpenRequest
HttpSendRequest

However I encountered another problem. I have to have totally customized message headers. WININET says that customization is supposed to be accomplished with editing/removal of headers by HttpAddRequestHeaders. I used this function and it failed! Here are the headers I could not remove:
"User-Agent"
"Cache-Control"
"Host"
Also I need to have the following POST header: "POST /authorize HTTP/1.0" WININET says that you can do this with HttpOpenRequest modifying 2nd and 4th parameter. It also failed. Perhaps the server I need to communicate to is not strictly HTTP (1.0 or 1.1) compliant. But this does not help me since I have no control on the server side. Since you said that you communicated with HTTPS servers, might be you encountered similar problems in the past. May be you know how to turn off the GET header in InternetOpenUrl or some other workarounds to create customized message, with the other functions of WININET or other DLL libraries that come with Windows?

Joshua Zavelovich

------------------

IP: Logged

Jakob Faarvang
Member
posted November 06, 2002 02:33 AM     Click Here to See the Profile for Jakob Faarvang     Edit/Delete Message   Reply w/Quote
Check out MS' documentatin on HTTP sessions at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/http_sessions.asp ..

That page contains a whole section on "Posting Data to the Server"..

But..

According to the documentation on InternetOpenUrl, you can send along headers with the InternetOpenUrl request:

quote:
lpszHeaders
[in] Pointer to a null-terminated string that specifies the headers to be sent to the HTTP server. (For more information, see the description of the lpszHeaders parameter in the HttpSendRequest function.)
dwHeadersLength
[in] Size of the additional headers, in TCHARs. If this parameter is -1L and lpszHeaders is not NULL, lpszHeaders is assumed to be zero-terminated (ASCIIZ) and the length is calculated.

Are you sure this is not enough for you? If it isn't, then you'll have to read up on the HTTP sessions as described above, but many webservers are "nice enough" to allow you send along post data with a get request...

Hope this helps..
Cheers,
- Jakob

IP: Logged

All times are EasternTime (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | PowerBASIC BASIC Compilers

Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.


Ultimate Bulletin Board 5.45c