HTTPS in PB?

Windows specific forum
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

HTTPS in PB?

Post by Kaiser »

Yeah, it is possible to get/send some data using the HTTPS protocol in PB? I've heard about WININET.DLL and that one source code in PureArea but doesn't seems to help me... or at least the code's way too hard for me to understand... but don't know anything about WININET.DLL nor how to use it in PB (A wrapper would do nicely) so... any way I can get/send data using HTTPS in PB?
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

If you're talking about a webserver there's a few examples, the Atomic Webserver an KNet (a program I've written) are just two and the source is included with PB or on the fourms.
~I see one problem with your reasoning: the fact is thats not a chicken~
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post by Kaiser »

By webserver you mean hosting or accessing it?
KameHameHaaa
User
User
Posts: 19
Joined: Wed Oct 05, 2005 2:44 pm

Post by KameHameHaaa »

This is an include file that I built "stealing" form this forum and adding other needed parts reading MSDN.

Code: Select all

; All stuff for the WinInet lib.
#INTERNET_OPEN_TYPE_DIRECT              = 1
#INTERNET_OPEN_TYPE_PRECONFIG           = 0
#HTTP_ADDREQ_FLAG_ADD                   = $20000000
#HTTP_ADDREQ_FLAG_REPLACE               = $80000000
#INTERNET_FLAG_SECURE                   = $800000
#INTERNET_FLAG_RELOAD                   = $80000000
#INTERNET_FLAG_PRAGMA_NOCACHE           = $100
#INTERNET_FLAG_KEEP_CONNECTION          = $400000
#INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP  = $8000
#INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS = $4000
#INTERNET_FLAG_IGNORE_CERT_CN_INVALID   = $1000
#INTERNET_FLAG_IGNORE_CERT_DATE_INVALID = $2000
#INTERNET_FLAG_EXISTING_CONNECT         = $20000000
  
; Type of connection (could be FTP Gopher etc). HTTPS is done as HTTP too.
#INTERNET_SERVICE_HTTP = 3

; custom
#INTERNET_HTTP_PORT=80
#INTERNET_HTTPS_PORT=443

;#INTERNET_FLAG_SECURE

Procedure.s do_post (host.s, url.s, login.s , password.s, port, secureflag)
  
  result.s = ""
 
  ; All from the wininet DLL
  open_handle = InternetOpen_("GR monitor",#INTERNET_OPEN_TYPE_PRECONFIG,"","",0); proxy;INTERNET_OPEN_TYPE_PRECONFIG;INTERNET_OPEN_TYPE_DIRECT
  connect_handle = InternetConnect_(open_handle,host,port,"","",#INTERNET_SERVICE_HTTP,0,0)
  request_handle = HttpOpenRequest_(connect_handle,"POST",url,"","",0,secureflag | #INTERNET_FLAG_IGNORE_CERT_CN_INVALID | #INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | #INTERNET_FLAG_RELOAD | #INTERNET_FLAG_PRAGMA_NOCACHE | #INTERNET_FLAG_KEEP_CONNECTION | #INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | #INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP,0)
  headers.s = "Content-Type: application/x-www-form-urlencoded" +Chr(13)+Chr(10) 

  HttpAddRequestHeaders_(request_handle,headers,Len(headers), #HTTP_ADDREQ_FLAG_REPLACE | #HTTP_ADDREQ_FLAG_ADD)

  post_data.s = "login=" + login +"&passwd=" + password + "&dataora=" + dataora
  post_data_len = Len(post_data)
  send_handle = HttpSendRequest_(request_handle,"",0,post_data,post_data_len)
 
  buffer.s = Space(1024)
  bytes_read.l = 0
  total_read.l = 0
 
  ; Read until we can't read anymore..
  ct=0
  Repeat
    z=InternetReadFile_(request_handle,@buffer,1024,@bytes_read)
    result + Left(buffer,bytes_read)
    buffer = Space(1024)
    ct+1
  Until bytes_read=0
  
  err.s=LastError()
  If err<>""
    result="<message>Error:" + Chr(13) + err + "</message>"
  EndIf

  ProcedureReturn result
EndProcedure 
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post by Kaiser »

Uh, that looks interesting... now how the hell does it work? I know that code snippet... and nice modification you made, but it didn't explained anything about the API commands there.... and the MSDN didn't helped me :?
Kaiser
Enthusiast
Enthusiast
Posts: 118
Joined: Tue Jan 11, 2005 8:36 am

Post by Kaiser »

Anyone? :S 'cause I'm making an MSN client and need to do the HTTPS authentication in it :/
Post Reply