1

There was an earlier implementation of get and post http request from C-language POS system to the server. However for reasons of security the server only accepts https on port 443.

The implementation has failed to work on port 443 indication http errors 400/362.

Here is sample code,

char *build_get_query(char *host, char *page)
    {
      char *query;
      char *getpage = page;
      char *tpl = "GET /%s HTTP/1.0\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n";
      /*if(getpage[0] == '/'){
        getpage = getpage + 1;
        fprintf(stderr,"Removing leading \"/\", converting %s to %s\n", page, getpage);
      } */
      // -5 is to consider the %s %s %s in tpl and the ending \0
      query = (char *)malloc(strlen(host)+strlen(getpage)+strlen(USERAGENT)+strlen(tpl)-5);
      sprintf(query, tpl, getpage, host, USERAGENT);
      return query;
    }

P.S no expert at C Thank you

acacia
  • 1,375
  • 1
  • 14
  • 40

1 Answers1

1

You can't send raw text with https it requires SSL or TLS. Depending on the platform you are working on you could use gnutls or openssl. And make your socket TLS capable to be able to send/recieve encrypted data to/from the server.

Iharob Al Asimi
  • 52,653
  • 6
  • 59
  • 97
  • Please share more details i can pass on to my developer – acacia Jan 15 '16 at 14:27
  • Why would you help your developer like that, hire another one. If you want write to iharob@gmail.com I am right now working on a library that does exactly what you need. With a `printf()` like funcionality and with TLS enabled or without it as needed. It's ready, write to me and we can talk about it. – Iharob Al Asimi Jan 15 '16 at 14:30