Hi,
I have working implementation of HTTP authentication using WinInet but I want to switch to BOOST::ASIO but I am not sure how to send the authentication request to HTTP server using BOOST::ASIO/SSL. Just to give an idea here is code snippet of the WinInet.
Is there any code sample available to do the same using boost::asio and SSL? How do we send user name and password using SSL is there any special function or we have to create our own request string, and how it is going to look like?
Here is the partial example code using WinInet
Connect(serverURL)/*https://someurl.com/… */
OpenRequest(“POST”,.....)
if(!InternetSetOption(m_hHttpConnection, INTERNET_OPTION_USERNAME,
(void*)string_cast<string>(userID).c_str(), userID.size()) ||
!InternetSetOption(m_hHttpConnection, INTERNET_OPTION_PASSWORD,
(void*)string_cast<string>(passWord).c_str(), passWord.size())
/*
Set some other security Flag
*/
)
{
m_lastResult = HRESULT_FROM_WIN32(GetLastError());
}
DWORD dwSize, dwCode;
dwSize = sizeof (DWORD) ;
if ( !HttpQueryInfo (m_hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL))
{
m_lastResult = HRESULT_FROM_WIN32(GetLastError());
return false;
}
Example code End.
Thanks,
Akhilesh
Note that WinInet has high-level API for HTTP requests, while asio
primarily deals with socket level.
> Is there any code sample available to do the same using boost::asio and SSL?
Yes, there's an example showing how to use ssl socket:
http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/example/ssl/client.cpp
and there's an example of HTTP client:
http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/example/http/client/async_client.cpp
Now you compose your own code that performs http requests over ssl.
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
With simple http request and response I can use the TCP viewer and see what is being transferred over the wire, that helps me creating the request in right format.
But authentication request over HTTPS are encrypted and I am not sure how it lo like, also WinInet provide a special method for setting username and password, so I am not sure how the request looks like.
That why I was wondering about the format in which user name and password will be sent?
So I am looking for login/authentication example using socket/boost::asio.
Thanks,
Akhilesh Kumar