How to use SSL or TLS on wxSocket ?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Sunsawe
Experienced Solver
Experienced Solver
Posts: 54
Joined: Tue Jan 30, 2007 5:04 pm

How to use SSL or TLS on wxSocket ?

Post by Sunsawe » Thu Mar 15, 2007 9:47 pm

Hi,

I saw that a question like that had already been asked but... the answer was not really... complete.

So i'm looking for a way to ssl or tls encrypt a connection open via a wxSocket. Something that already exists please....

Did someone already try it?
Is there any guide about how to do it?

Thanks

:)

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Fri Mar 16, 2007 8:21 am

Hi!
There used to be a project called wxSSL, but it seems like it was abandoned long ago.
However, wxCURL might offer a solution. As far as I understood it, you'll have to download and compile libcurl with SSL support, then compile wxCURL. It seems like you can pass curl options then, have a look at the curl docs for a reference and examples.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

cd_hodges
Earned some good credits
Earned some good credits
Posts: 145
Joined: Thu Feb 03, 2005 4:46 pm

Post by cd_hodges » Fri Mar 16, 2007 9:02 pm

I just went through this exercise yesterday with my app and here is what you have to do:

1) Download and compile OpenSSL
2) Download and compile curl passing the compilation arguments to include SSL support
3) Download the wxCURL library and include it in your project.

You can compile the OpenSSL and CURL packages as either static or DLLs.

So far this has worked out well for me -- no complaints yet.

Chris

Sunsawe
Experienced Solver
Experienced Solver
Posts: 54
Joined: Tue Jan 30, 2007 5:04 pm

Post by Sunsawe » Sat Mar 17, 2007 8:08 pm

Hi,

I tried to follow your advices. Everything is ok with openssl and libcurl.

I downloaded wxCurl, defined the variables that were needed and i opened the curl_envvar.vcproj.
When i tried to compile wxCurl, i had these errors:

Code: Select all

Compiling...
base.cpp
..\..\src\curl\base.cpp(16) : fatal error C1083: Cannot open precompiled header file: 'vc_mswd\wxprec_curllib.pch': No such file or directory
dav.cpp
..\..\src\curl\dav.cpp(20) : fatal error C1083: Cannot open precompiled header file: 'vc_mswd\wxprec_curllib.pch': No such file or directory
davtool.cpp
..\..\src\curl\davtool.cpp(20) : fatal error C1083: Cannot open precompiled header file: 'vc_mswd\wxprec_curllib.pch': No such file or directory
dummy.cpp
..\..\..\..\..\..\..\..\DEV\wxWidgets-2.8.0\src\common\dummy.cpp(20) : fatal error C1083: Cannot open precompiled header file: 'vc_mswd\wxprec_curllib.pch': No such file or directory
The last ligne gives this path because i changed the dummy.cpp in the project. Before, i had this error:

Code: Select all

c1xx : fatal error C1083: Cannot open source file: '.\%wxwidgets%\src\msw\dummy.cpp': No such file or directory
So i deleted it and had the one in wxWidgets.

if i try without the precompiled header, it's worst.

I searched on the computer and the wxprec_curllib.pch doesn't exist. worst, google doesn't know anything about it.
Can you help me?

cd_hodges
Earned some good credits
Earned some good credits
Posts: 145
Joined: Thu Feb 03, 2005 4:46 pm

Post by cd_hodges » Mon Mar 19, 2007 2:01 pm

Ahhh I didn't use the Visual C++ project file. I actually created them using the makefiles. Try to do it that way and see what happens.

Chris

P.S. - Also check your private mail.

Sunsawe
Experienced Solver
Experienced Solver
Posts: 54
Joined: Tue Jan 30, 2007 5:04 pm

Post by Sunsawe » Mon Mar 19, 2007 10:06 pm

well, that is even more... weird!

I downloaded wxCurl and i also used the CVS repository to be sure that i had the last version.

The thing is that i found absolutely no makefile in!! :shock:

i'm starting to think that i don't have the right one.
Is there only one wxCurl? on sourceforge?
the last update is around 2 years old right?

Something else, in my last post i gave the error that i had.
I noticed that the precompiled header error is thrown when i use "build" and the dummy.cpp file error is thrown when i use "rebuild"...

really don't know what to do.
Can somebody explain in details how he or she compiled this???
:roll:

eranif
Moderator
Moderator
Posts: 607
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif » Mon Mar 19, 2007 11:00 pm

why dont you simply download curl from here:
(not wxCurl) http://curl.haxx.se/download.html and build it?

Make sure you select the one with SSL enabled.
Should be easy.
Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org

Sunsawe
Experienced Solver
Experienced Solver
Posts: 54
Joined: Tue Jan 30, 2007 5:04 pm

Post by Sunsawe » Tue Mar 20, 2007 4:06 am

Well... Actually... as i said, i did install curl and openssl.

If i understood, wxCurl is a wrapper to use curl in wxWidgets.

Don't i need this??

On an other side some succeeded to install wxCurl so it should not be impossible. The errors i'm talking about are so easy to reproduce that it must be also easy to see what is going on.

I must miss a step somewhere and i need someone, who did it, to tell me where.
Because if you download wxCurl, open the visual studio project, compile it, as it is, and you don't have these errors, to me it means, that we are not compiling the same thing.

Or maybe you are using a special directory.

that is the kind of details i'm almost looking for now. I want to understand what is going, can't believe that for some strange magic, i'm the only one on earth who can't compile wxCurl. lol
:D

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Tue Mar 20, 2007 11:10 pm

If i understood, wxCurl is a wrapper to use curl in wxWidgets.

Don't i need this??
A wxWidgets program doesn't need to take the entirety of its functionality from wxWidgets, it can link against other libs as well. You could have wxWidgets do the GUI and curl do the networking.

wxCurl would probably have been more integrated with wxWidgets than Curl, but nothing prevents you from using Curl.

You should perhaps check if wxCurl is still maintained - contact its author if yes, drop it in favor of curl if no. Just my suggestion anyway.

Sunsawe
Experienced Solver
Experienced Solver
Posts: 54
Joined: Tue Jan 30, 2007 5:04 pm

Post by Sunsawe » Fri Mar 23, 2007 7:48 am

Hi,

I figured out that a lot of my problems were related to vs2005 configuration and way to update project's files to new version (absolute path transformed in relative path, use of %VAR% in previous version and $(VAR) in new...)

I changed many things and i succeeded to have the compilation starting.

Now the problem is that dummy.obj, which is the first thing to be compiled, is in fact, never produced. Thus i have this error:

Code: Select all

------ Build started: Project: curl, Configuration: Unicode Release Win32 ------
Compiling...
dummy.cpp
Compiling...
telnet.cpp
http.cpp
ftpparse.cpp
ftptool.cpp
ftp.cpp
davtool.cpp
dav.cpp
base.cpp
Creating library...
LIB : fatal error LNK1181: cannot open input file '.\vc_mswu\curl\dummy.obj'
Build log was saved at "file://c:\DEV\wxCurl\wxCURL\build\curl\vc_mswu\curl\BuildLog.htm"
Does anyone know how to solve that? or just an idea about why this file could not be produced evenif there is no compile error?

Thanks

Sunsawe
Experienced Solver
Experienced Solver
Posts: 54
Joined: Tue Jan 30, 2007 5:04 pm

Post by Sunsawe » Tue Apr 17, 2007 6:26 am

Well,

I finally succeeded to compile wxCurl but...
Can't find any tutorial on how to use it...

I saw a lot of things in it and read the libcurl doc but... so complicated... :oops:
Everything seems to be linked to the protocol (ftp, http...) that is used.

Me, i just want to open a socket then switch it to an encrypted connection via a starttls command.
How can i do that?

Is there a way to re-use a wxSocket previously opened for that?

thanks

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Tue Apr 17, 2007 7:08 am

Hi!
Sunsawe wrote:Me, i just want to open a socket then switch it to an encrypted connection via a starttls command.
How can i do that?
As far as I remember I posted a link for Cram-MD5 authentication here http://forums.wxwidgets.org/viewtopic.php?p=57855#57855.
Encryption always depends on the higher level protocol used. You authenticate, negotiate some keys for encryption and then encrypt data on the sender side and decrypt it on the receiving side using the keys. You can't simply "switch" to an encrypted socket. HTTPS for example is a "special" HTTP connection that encrypts and decrypts data. You'll have to think about what you want to do first.

So, what exactly do you want to do?
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

Sunsawe
Experienced Solver
Experienced Solver
Posts: 54
Joined: Tue Jan 30, 2007 5:04 pm

Post by Sunsawe » Tue Apr 17, 2007 3:33 pm

Actually, i'm still working on the same project.
I'm just trying to built a little smtp client that deals with authentication.

Smtp servers like gmail require an ssl/tls connection to proceed.

Knowing that first the connection should be opened then the STARTTLS command should be sent by the client.

This is exactly what i'm trying to do.

I understood that it was working a little like for ftp. You can first open a normal connection then send a command to start the ssl handshake other it.
Isn't it the same thing there?

Post Reply