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++ Library : Other (not classified elsewhere) » HTTPS?
Re: HTTPS? [message #6864 is a reply to message #6861] Fri, 01 December 2006 20:36 Go to previous messageGo to previous message
rylek is currently offline  rylek
Messages: 79
Registered: November 2005
Member
Hi!

This is a short snippet of code I use in a commercial application to get the SSL sockets up and running. I suppose it solves a very specific situation but I hope you'll be able to use it at least to stumble upon some ideas.

Regards

Tomas

	socket.Clear();
	if(encrypt) {
		if(!ssl_context) {
			ssl_context = new SSLContext;
			if(!ssl_context->Create(SSLv3_client_method())) {
				WhenConsole(NFormat("Error creating SSL context: %s", SSLGetLastError()), 0);
				return false;
			}
			if(!IsNull(certificate_file) || !IsNull(private_key_file)) {
				String cdata = LoadFile(certificate_file);
				if(IsNull(cdata)) {
					WhenConsole(NFormat("Error reading certificate file '%s'.", certificate_file), 0);
					return false;
				}
				String pdata = LoadFile(private_key_file);
				if(IsNull(pdata)) {
					WhenConsole(NFormat("Error reading private key file '%s'.", private_key_file), 0);
					return false;
				}
				if(!ssl_context->UseCertificate(cdata, pdata)) {
					WhenConsole(NFormat("Invalid certificate '%s' / private key '%s': %s",
						certificate_file, private_key_file, SSLGetLastError()), 0);
					return false;
				}
			}
		}
		SSLClientSocket(socket, *ssl_context, host, port, true, NULL, timeout_msecs);
	}
	else
		ClientSocket(socket, host, port, true, NULL, timeout_msecs);
	if(!socket.IsOpen()) {
		WhenConsole(NFormat(t_("Error opening socket %s:%d: %s\n"), host, port, Socket::GetErrorText()), 0);
		return false;
	}

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Input value at main ()
Next Topic: GridCtrl bug?
Goto Forum:
  


Current Time: Mon May 13 04:30:16 CEST 2024

Total time taken to generate the page: 0.02052 seconds