PDA

View Full Version : need help with posting tweets HTTPS request with ssl



k1447321
3rd September 2015, 09:34
Hi,
I'm an intern at an IT frim and my first duty is to make an console app that sends tweets. I successfully created my header and right now I can sent my HTTPS posts with the header I created . But having an authroization problem altough I'm sure I have correct token and secret values. So I made a research and I found information in this site (https://dev.twitter.com/overview/api/ssl) that says I should use cipher and certificates. My question is since I already installed openssl(havent written any extra code for it but ot having any ssl errors) should I do anything extra and if I should could you please show me how to add cipher(rc4) and certificate(cacert.pem I guess) to my request.

I found about sslsocket but can I add query and http header to it?

Here is the code :

QNetworkRequest request(url);// url is "https://api.twitter.com/1.1/statuses/update.json"
request.setRawHeader(O2_HTTP_AUTHORIZATION_HEADER, buildAuthorizationHeader(oauthParams));
request.setHeader(QNetworkRequest::ContentTypeHead er, O2_MIME_TYPE_XFORM);
// manager->post(request, postData);

note: my requests seems right since I can do the pin and token gathering processes

thanks :)

anda_skoa
3rd September 2015, 10:42
Maybe usingQNetworkRequest::setSslConfiguration()?

Cheers,
_

k1447321
3rd September 2015, 13:02
hey,
thank you for your suggestion I added an cacert and cipher using the info you gave my cipher is rc4-sha and my cacert is from this site (http://www.cacert.org/index.php?id=3) and is called Class 3 PKI Key Intermediate Certificate (PEM Format). but now I'm having
http status: 0. do you people any idea about this?

ChrisW67
3rd September 2015, 22:51
Where are you getting the value zero from?

Zero from QNetworkReply::error() is no errror.

k1447321
4th September 2015, 07:47
I'm sending my post to the twitter api and I get an http status code 0 from there. I used to get codes like 401 not authorized but now all I get is http status code 0. I added cipher(rc4-sha) ,certificate(cacert) , and protocol(sslv3) but still having the same problem
thanks anyway :)

ChrisW67
4th September 2015, 23:00
What is the raw text of the entire response? Are there valid HTTP headers or just a dropped connection?
Ensure that the form of your POST body is correct.

Have you tried putting Fiddler (http://www.telerik.com/fiddler) between your application and the Twit servers to observe the raw interaction? (Yes, it can MITM your SSL)

k1447321
7th September 2015, 08:49
""
http status: 0 this is the reply I get from twitter. this happens at the last (posting tweet) phase. other than that receiving replies from twitter works and I can get my oauth data. my request is correct atleast the headers and the body since it works perfectly with the cUrl. my problem is I still dont know how to send a post with ssl. as far as I know I need to include cacert.pem and make handshake with the host. If you can help me with a working https post or a libcurl implementation that would be great.