Re: HTTPS with OpenSSL

new topic     » goto parent     » topic index » view thread      » older message » newer message

I built my own wininet wrapper. Source code is here: http://jean-marc.duro.pagesperso-orange.fr/WININET.e

I ran following code:

include get.e 
include Wininet.e 
 
  sequence aBuffer, s 
  sequence Header 
  atom pSession, pConnection, pRequest 
  integer res, f_out 
 
  sequence Result 
 
  sequence AData 
 
  AData = "\"_username\": \"myUsername\", \"_password\": \"myPassword\", \"_submit\": \"\"" 
  Result = "" 
  f_out = open("geneanet.htm", "w") 
  pSession = InternetOpen("Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0", 0, NULL, NULL, 0) 
  if pSession > 0 then 
    pConnection = InternetConnect(pSession, "geneanet.org", 
                                  INTERNET_DEFAULT_HTTPS_PORT, 
                                  NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0) 
 
    if pConnection > 0 then 
      pRequest = HttpOpenRequest(pConnection, "POST", "/connexion/", NULL, NULL, NULL, 
                                 or_bits(INTERNET_FLAG_SECURE, INTERNET_FLAG_KEEP_CONNECTION), 0) 
 
      if pRequest > 0 then 
        Header = "Host: geneanet.org" & 10 & 
          "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0" & 10 & 
          "Accept: text/html,application/xhtml&xml,application/xml;q=0.9,*/*;q=0.8" & 10 & 
          "Accept-Language: en-us,en;q=0.5" & 10 & 
          "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & 10 & 
          "Keep-Alive: 300" & 10 & 
          "Connection: keep-alive"& 10 & 10 
 
        res = HttpAddRequestHeaders(pRequest, Header, HTTP_ADDREQ_FLAG_ADD) 
 
        if HttpSendRequest(pRequest, NULL, AData) then 
 
          aBuffer = "" 
          s = InternetReadFile(pRequest, 4096) 
          while length(s) do 
            aBuffer &= s 
            s = InternetReadFile(pRequest, 4096) 
          end while 
        end if 
 
        res = InternetCloseHandle(pRequest) 
      else 
        puts(1, sys_FormatMessage(GetError()) & "\n") 
      end if 
 
      res = InternetCloseHandle(pConnection) 
    else 
      puts(1, sys_FormatMessage(GetError()) & "\n") 
    end if 
 
    res = InternetCloseHandle(pSession) 
  else 
    puts(1, sys_FormatMessage(GetError()) & "\n") 
  end if 
  puts(f_out, aBuffer) 
  close(f_out) 
  puts(1, "Press any key ...\n") 
  res = wait_key() 
 

Apart of authentication problems (Geneanet needs CSRF tokens), this seems to work.

Jean-Marc

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu