ksslsession.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include "ksslsession.h"
00022
00023
#ifdef HAVE_CONFIG_H
00024
#include <config.h>
00025
#endif
00026
00027
#include <kopenssl.h>
00028
#include <kmdcodec.h>
00029
00030 KSSLSession::KSSLSession() : _session(0L) {
00031 }
00032
00033
00034 KSSLSession::~KSSLSession() {
00035
#ifdef KSSL_HAVE_SSL
00036
if (_session) {
00037
KOpenSSLProxy::self()->
SSL_SESSION_free(static_cast<SSL_SESSION*>(_session));
00038 _session = 0L;
00039 }
00040
#endif
00041
}
00042
00043
00044 QString KSSLSession::toString()
const {
00045
QString rc;
00046
#ifdef KSSL_HAVE_SSL
00047
QByteArray qba;
00048 SSL_SESSION *session = static_cast<SSL_SESSION*>(_session);
00049
unsigned int slen =
KOpenSSLProxy::self()->
i2d_SSL_SESSION(session, 0L);
00050
00051
00052
char *csess =
new char[slen];
00053
char *p = csess;
00054
00055
if (!
KOpenSSLProxy::self()->
i2d_SSL_SESSION(session, (
unsigned char **)&p)) {
00056
delete[] csess;
00057
return QString::null;
00058 }
00059
00060
00061 qba.duplicate(csess, slen);
00062
delete[] csess;
00063 rc = KCodecs::base64Encode(qba);
00064
#endif
00065
return rc;
00066 }
00067
00068
00069 KSSLSession *
KSSLSession::fromString(
const QString& s) {
00070
KSSLSession *session = 0L;
00071
#ifdef KSSL_HAVE_SSL
00072
QByteArray qba, qbb = s.
local8Bit().copy();
00073 KCodecs::base64Decode(qbb, qba);
00074
unsigned char *qbap = reinterpret_cast<unsigned char *>(qba.data());
00075 SSL_SESSION *ss = KOSSL::self()->d2i_SSL_SESSION(0L, &qbap, qba.size());
00076
if (ss) {
00077 session =
new KSSLSession;
00078 session->
_session = ss;
00079 }
00080
#endif
00081
return session;
00082 }
00083
00084
This file is part of the documentation for kio Library Version 3.4.0.