views:

812

answers:

5

Hi,

I've an MFC application that currently uses CAtlHttpClient to query a web server for some information.

I'd like to change this so that the query goes over securely, with server authentication, using SSL.

Googling reveals that Microsoft has changed the way they support this several times, e.g., WinInet, WinHTTP, but for the life of me I can't figure out how to do the above using MFC under MSVS 2005.

The application is in C++, and if at all possible, I'd like to avoid dragging .Net into the picture.

Any help, hints, suggestions or pointers gratefully appreciated!

Thanks,

ony

+2  A: 

Back in 2002 I wrote an article for Windows Developer Magazine that showed how to use OpenSSL to provide SSL for MFC's CAsyncSocket. The code and article are here: http://www.lenholgate.com/archives/000456.html and might help you.You could also do something similar using Microsoft's SChannel but it's a little more involved as OpenSSL does some of the buffering for you so all you need to do is push bytes into it until you get clear text out...

Len Holgate
Thanks - nice article!I'd prefer a solution that allows me to leverage on Microsoft's code, though, rather than haul in OpenSSL. SChannels seem a bit too low-level...Thanks again.Rony
ronys
+4  A: 

You could take a look at Ultimate TCP/IP - it is MS friendly and might do what you're after:

http://www.codeproject.com/KB/MFC/UltimateTCPIP.aspx

I use this toolkit and it's very good.

Rob
Thanks for the pointer - looks like a useful toolkit, although perhaps a bit of an overkill for my project.Also, the license is "The Code Project Open License (CPOL) 1.02", which isn't among the OSI approved licenses in http://opensource.org/licenses.Rony
ronys
... What, so using MFC is ok, but a free license that isn't 'OSI approved' isn't? And because it doesn't do exactly what you need but a bit more it's 'overkill'? If you don't like the answers, don't ask the question...
Roel
The beauty of Ultimate TCP/IP is that you only need to compile in the parts you want - in this case just the HTTPS support - hardly overkill IMHO.
Rob
+2  A: 

Found a pointer to some Microsoft sample code which might fit the bill: http://msdn.microsoft.com/en-us/library/s2ya483s(VS.80).aspx

However this fails on AcquireCredentialsHandle, which will be my next question to this august forum...

ronys
A: 

What about using the libeay32.dll and ssleay32.dll files that come as part of OpenSSL:

http://www.deanlee.cn/programming/openssl-for-windows/

jussij
A: 

Just use WinHttp, It's a great API and has all you need to do SSL over HTTP (plus works with the Proxy configuration of Vista going forward)