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 |
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;
}
|
|
|
|
|
HTTPS?
By: zsolt on Fri, 01 December 2006 13:59
|
|
|
Re: HTTPS?
By: mirek on Fri, 01 December 2006 14:03
|
|
|
Re: HTTPS?
By: zsolt on Fri, 01 December 2006 14:30
|
|
|
Re: HTTPS?
|
|
|
Re: HTTPS?
By: rylek on Fri, 01 December 2006 19:22
|
|
|
Re: HTTPS?
By: mirek on Fri, 01 December 2006 19:41
|
|
|
Re: HTTPS?
By: zsolt on Fri, 01 December 2006 20:10
|
|
|
Re: HTTPS?
By: zsolt on Fri, 01 December 2006 20:17
|
|
|
Re: HTTPS?
By: rylek on Fri, 01 December 2006 20:36
|
|
|
Re: HTTPS?
By: mirek on Fri, 01 December 2006 20:23
|
|
|
Re: HTTPS?
By: rylek on Fri, 01 December 2006 20:29
|
|
|
Re: HTTPS?
By: mirek on Fri, 01 December 2006 20:43
|
|
|
Re: HTTPS?
By: rylek on Fri, 01 December 2006 21:07
|
|
|
Re: HTTPS?
By: mirek on Fri, 01 December 2006 21:22
|
|
|
Re: HTTPS?
By: Weras on Mon, 31 August 2009 23:13
|
|
|
Re: HTTPS?
By: rylek on Wed, 02 September 2009 23:18
|
Goto Forum:
Current Time: Mon May 13 04:30:16 CEST 2024
Total time taken to generate the page: 0.02052 seconds
|