Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » https - how to?
https - how to? [message #7937] Thu, 01 February 2007 09:21 Go to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi all!

I played around with HttpClient a few weeks ago. Works fine - but then I tried to use https. But I didnt get the demo running. I tried to include openssl - but without success.

Is there any demo of a "HttpsClient"?

Thanks,

WebChaot.
Re: https - how to? [message #7940 is a reply to message #7937] Thu, 01 February 2007 10:00 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
Hi,

Https is just HTTP over SSL, so you have to enable ssl for your socket.

OpenSSL is already included in Upp, the only thing you have to do is enable ssl at the socket.

Have a look at
HTTPs Thread in the Forum


Bas
Re: https - how to? [message #8496 is a reply to message #7937] Wed, 14 March 2007 12:21 Go to previous messageGo to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi fallingdutch!

I found the thread you linked a few weeks ago. But it doesnt help, because I do not know, where to implement this piece of code. Will I have to create a new class based on HttpClient and put this code in some socket functions?

You also wrote, that openssl is included in upp. I played around with httpclient only once - but was not able to run any ssl demo, because of missing openssl-files. Maybe now it will work. I will download the last release next week and try again.

WebChaot.
Re: https - how to? [message #8665 is a reply to message #8496] Fri, 23 March 2007 08:49 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
Hi WebChaot,

this piece of code just initializes the communication - so you will add it before you start any communication.

you could also have a look at the XmlRpc Server at my site (it is at the moment out of date, but a new will come soon)


Bas
Re: https - how to? [message #8963 is a reply to message #7937] Tue, 10 April 2007 14:12 Go to previous messageGo to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi fallingdutch!

I played around a little bit with https last week. Or better: I tried to.

You wrote: "openssl is already included in Upp, the only thing you have to do is enable ssl at the socket."

I use the windows installer version of upp - and there is no openssl anywhere. Then I thought, maybe its only included in sources (zip-file) - but there is also no openssl.

Which version of upp do you use? What should I do now to get openssl-files? It would not be a problem to get the files from openssl-site. But does it matter, which version I use?

>>> you could also have a look at the XmlRpc Server at my site (it is at the moment out of date, but a new will come soon)

I downloaded your code and it helps me to understand many things. Thanks a lot. But at the moment I'm not able to run any ssl-demo, because missing ssl-files. I got an error in WebSSL on following lines:

#include <openssl/ssl.h>
#include <openssl/err.h>


WebChaot
Re: https - how to? [message #8981 is a reply to message #8963] Wed, 11 April 2007 09:40 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
i always use the latest code (release and development)

I am sorry, but it seems like OpenSSL is NOT included in Upp.
You can download it here:
http://www.slproweb.com/products/Win32OpenSSL.html

My OS is Ubuntu 6.10 (Linux)


Bas
PS: If you have any problems just let me know
Re: https - how to? [message #9187 is a reply to message #7937] Fri, 20 April 2007 10:37 Go to previous messageGo to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
>>> PS: If you have any problems just let me know

Thanks - now I have some Smile

>>> I am sorry, but it seems like OpenSSL is NOT included in Upp.

I downloaded openssl. First I got an linker error (file not found: libout32/xy.a) - but then I copied the *.a files to new mingw-dir libout32 and it works.

Then I put the code of your xmlrpc into my program (because I do not know, how to do all that stuff):

--------------------------------
if(usessl)
{
if(sslcontext.IsEmpty())
{
SSL_METHOD *meth=TLSv1_client_method();
sslcontext.Create(meth);
sslcontext.VerifyPeer(false);
}

if(!SSLClientSocket(http.socket,sslcontext,http.host,http.po rt))
{
PromptOK("No SSL");
return;
}

MyResult = http.Execute();
--------------------------------

1. What I get, when I download an URL (https://...) is only a "No SSL" which still results from SSLClientSocket. Is there any way to check, whats wrong now?

And how does it work? When I disable usessl, but connect to an "https"-site, I get a response. Will I have to parse URL for the "s" by code to check, if I have to "usessl"?

First I want to get any response from a https-site. Then I will continue to play around with certificates.

2. I tried to get content of an local webserver via http://192.168.x.y (without ssl) and the program hang up. Does it not work with ip-adresses?

3. After first run I got an error message because of missing msvcr71.dll. I downloaded it and copied to windows dir. As I read its a c-runtime-library. I thought, when I have all openssl-sources I would not need any extra dll. Is there a way to include openssl without a dll (because I only want one exe-file, if possible)?


WebChaot

PS: We could talk in german too - but this forum is international - greetings from Vienna Smile

[Updated on: Fri, 20 April 2007 11:07]

Report message to a moderator

Re: https - how to? [message #9236 is a reply to message #9187] Mon, 23 April 2007 08:55 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
Hi WebChaot, sorry for the late reply, my box was down.

WebChaot wrote on Fri, 20 April 2007 10:37


if(usessl)
{
if(sslcontext.IsEmpty())
{
SSL_METHOD *meth=TLSv1_client_method();
sslcontext.Create(meth);
sslcontext.VerifyPeer(false);
}

if(!SSLClientSocket(http.socket,sslcontext,http.host,http.po rt))
{
PromptOK("No SSL");
return;
}

MyResult = http.Execute();

1. What I get, when I download an URL (https://...) is only a "No SSL" which still results from SSLClientSocket. Is there any way to check, whats wrong now?


The bold line could be the problem, i used the newest encryption in my server/client but the webserver you are connecting might not be - so you should use one of the following
const SSL_METHOD *SSLv2_client_method(void);
const SSL_METHOD *SSLv3_client_method(void);

Quote:


And how does it work? When I disable usessl, but connect to an "https"-site, I get a response. Will I have to parse URL for the "s" by code to check, if I have to "usessl"?


Many Servers reply with a "you should connect to this server usring ssl" site.
Well if you just have a url: Yes because in normal case https is on port 443 and http on port 80. So you even have to connect to different ports.

Quote:


First I want to get any response from a https-site. Then I will continue to play around with certificates.


i hope you will be able if you play around with the changes above Smile

Quote:


2. I tried to get content of an local webserver via http://192.168.x.y (without ssl) and the program hang up. Does it not work with ip-adresses?


what do you set as port and host?
you have to set the ip as host and port to 80 to connect to a http-server

Quote:


3. After first run I got an error message because of missing msvcr71.dll. I downloaded it and copied to windows dir. As I read its a c-runtime-library. I thought, when I have all openssl-sources I would not need any extra dll. Is there a way to include openssl without a dll (because I only want one exe-file, if possible)?


I am Sorry, but i don't know - using linux here, but will soon play with windows, too.

greetings from Baden-Württemberg
Bas


Re: https - how to? [message #9262 is a reply to message #7937] Tue, 24 April 2007 14:07 Go to previous messageGo to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi fallingdutch!

Thanks for your help! Step for step it works. The problem was "URL". When I assign values manually (Port, Host, ...) it works. Now I have to pack all the stuff into a thread, because I dont want the application to freeze. I know the solution from forum with the callback in execute - but its not really fluid.

>>> First I want to get any response from a https-site. Then I will continue to play around with certificates.

Is there any way to read values out (certid, cn, ...) of server certificate? I cant find any method to do this.


WebChaot.

[Updated on: Wed, 25 April 2007 08:30]

Report message to a moderator

Re: https - how to? [message #9263 is a reply to message #9262] Tue, 24 April 2007 14:32 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
WebChaot wrote on Tue, 24 April 2007 14:07


Thanks for your help! Step for step it works. The problem was "URL". When I assign values manually (Port, Host, ...) it works. Now I have to pack all the staff into a thread, because I dont want the application to freeze. I know the solution in from forum with the callback in execute - but its not really fluid.


You are welcome. We are working on a better solution for that at the moment (have a look at the discussion in technology)
Quote:


Is there any way to read values out (certid, cn, ...) of server certificate? I cant find any method to do this.


As far as i remember (without checking the code) there is none, so you need to use the openssl primitive functions, you will have to search at OpenSSL

Bas
Re: https - how to? [message #9278 is a reply to message #7937] Wed, 25 April 2007 10:49 Go to previous messageGo to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi fallingdutch!

>>> As far as i remember (without checking the code) there is none, so you need to use the openssl primitive functions, you will have to search at OpenSSL

I found some functions in WebSSL.h to read data out of certificate. After testing a while its easy (and still implemented).

I put an example here for others:

client.socket.GetInfo(SSLInfoCertSubjectName()).ToString();

All other certificate related types can be found at bottom of WebSSL.h. The information must be read after SSLClientSocket() but before Execute()!


Thanks a lot again. I will continue work on my program at weekend - maybe I will post here again in a few days Smile

WebChaot.
Re: https - how to? [message #9303 is a reply to message #7937] Thu, 26 April 2007 09:24 Go to previous message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi fallingdutch!

All seems to work ok, but ... Smile


I implemented SSL in httpcli-Demo and in my own program.

In httpcli I allways get an zero return error from ssl socket - but code 200 from http - so all works fine, but I dont know, what I should do with this error.

In my own program on first download all works fine and I get the same error after first try (error: 0 - invalid server response...).

[error] socket(1904) / SSL_read: SSL_ERROR_ZERO_RETURN (6)
[status 200] HTTP/1.1 200 OK


Do you know whats wrong with ssl? Did you have similar responses in past?


Thanks,

WebChaot.


Here the lines I added to httpcli, which results in the error described above:

===========================================
if(sslcontext.IsEmpty())
{
sslcontext.Create(SSLv2_client_method());
sslcontext.VerifyPeer(false);
}

if(!SSLClientSocket(client.socket,sslcontext,client.host,cli ent.port))
{
puts("No SSL");
return;
}

if (!client.socket.IsOpen())
{
puts("No Socket");
return;
}

puts(client.socket.GetInfo(SSLInfoCertSubjectName()).ToStrin g());

String content = client.ExecuteRedirect();

puts("[error] " + Nvl(client.GetError(), "OK (no error)"));
puts(NFormat("[status %d] %s\n", client.GetStatusCode(), client.GetStatusLine()));
===========================================

[Updated on: Thu, 26 April 2007 09:25]

Report message to a moderator

Previous Topic: SlaveProcess and working directory
Next Topic: MT assertion failed in IsST()
Goto Forum:
  


Current Time: Thu Mar 28 16:13:33 CET 2024

Total time taken to generate the page: 0.01191 seconds