Jeroen Posted October 10, 2016 Share Posted October 10, 2016 Hello, I'm trying to code some module on my Tetra. I want to make a SSL https-request to a server including POST vars. But it seems that i cannot do a HttpRequest. I tried to use cURL (not implemented?) and file_get_contents (always FALSE) but still i'm wondering how to to this. PHP 5.6.17, Python 2.7, Tetra 1.1.1 What do i miss, doing wrong or misunderstand?? Quote Link to comment Share on other sites More sharing options...
pentestgeek Posted October 10, 2016 Share Posted October 10, 2016 cURL is what you want, what do you mean not implemented? Quote Link to comment Share on other sites More sharing options...
Jeroen Posted October 10, 2016 Author Share Posted October 10, 2016 I would love to because cURL is my favourite but i couldn't even do a curl_init(); afterwards script immediatly crashes. (sorry i don't have a snippet here at this moment) Quote Link to comment Share on other sites More sharing options...
Sebkinne Posted October 10, 2016 Share Posted October 10, 2016 Hi Jeroen, This is how you would send POST data with pure PHP. If you also want to post to HTTPS, you would need to combine it with the following code: <?php $context = stream_context_create(["ssl" => ["verify_peer" => true, "cafile" => "/etc/ssl/certs/cacert.pem"]]); $data = @file_get_contents("https://www.wifipineapple.com/tetra/bulletin", false, $context); You can see that you need the "ssl" portion for SSL, and that you need "http" part for the POST request and data. Quote Link to comment Share on other sites More sharing options...
Jeroen Posted October 11, 2016 Author Share Posted October 11, 2016 Thank you, Sebkinne, this worked, i made an error in building the context stream. But i see you're also using file_get_contents, instead of cURL. I prefer to use cURL because it is a little faster. The script isn't doing much most of the time. It sends real time log entries to another system, the receiver does not accept multiple entries. Especially when starting, it could burst >100 entries instantly, therefore the processing time is more or less relevant. Anyway, working fine now; thanks! Quote Link to comment Share on other sites More sharing options...
silurian Posted November 1, 2016 Share Posted November 1, 2016 Hey Jeroen, For the record if you want to do HTTP(s) requests with PHP then it's nice and easy to use then Guzzle(http://docs.guzzlephp.org/en/latest/) is a great option, the syntax is easy and it has a nice api which is transport agnostic. Think of it as syntactic sugar. (Also if you're concerned about speed to that level I'd suggest not using PHP and perhaps considering another language) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.